Home / Developer tools / Query string tool

Query String Parser and Builder

Paste a URL or a query string to see every parameter decoded in a table, or write key=value lines and get a correctly encoded query string.

Try:

Everything runs in your browser. Your text is not sent to our server.

What a query string is

The query string is the part of a URL between ? and an optional #. It holds parameters written as key=value and separated by &:

https://example.com/shop?cat=shoes&size=42&q=running%20shoes#reviews
                         \_____________________________/ \______/
                                   query string          fragment

Keys and values are percent-encoded, so that a value may contain &, = or a space without breaking the structure.

Parse mode

Paste a full URL or only the query part. The tool splits the address into base, query and fragment, decodes each key and value (with + read as a space), and shows them in a table next to the raw text. It also produces JSON. A key that appears more than once, such as color=red&color=blue, becomes an array in the JSON and is reported in a warning, because languages differ in how they read repeated keys:

  • PHP keeps only the last value, unless the key ends in [].
  • JavaScript URLSearchParams.get() returns the first value and getAll() returns all of them.
  • Python parse_qs returns a list for every key.

Build mode

Write one parameter per line as key=value. Everything after the first = is the value, so it can contain more = signs. Keys and values are encoded separately, and you choose whether a space becomes %20 (safe everywhere) or + (form style). Options: sort the keys alphabetically, which gives stable URLs for caching and signatures, and add a leading ?.

q=running shoes
city=São Paulo
price=10-20 & up

becomes

q=running%20shoes&city=S%C3%A3o%20Paulo&price=10-20%20%26%20up

Good practice for query strings

  • Encode each value separately, then join with &. Never encode the finished string, or the & and = signs are lost.
  • Use %2B for a real plus sign. A bare + is read as a space.
  • Keep keys simple (letters, digits, _ and -) so they need no encoding.
  • Do not put secrets in a query string. URLs are stored in browser history, server logs and referrer headers.
  • Put tracking parameters (utm_source and similar) after the real ones and use a consistent order, so that caches and analytics see one URL, not many.

Build a query string in code

// JavaScript
new URLSearchParams({q: 'running shoes', city: 'São Paulo'}).toString();
// "q=running+shoes&city=S%C3%A3o+Paulo"

// PHP
http_build_query(['q' => 'running shoes', 'city' => 'São Paulo'], '', '&', PHP_QUERY_RFC3986);

# Python
from urllib.parse import urlencode
urlencode({'q': 'running shoes', 'city': 'São Paulo'}, quote_via=quote)

Related tools: URL encoder, URL decoder, WhatsApp message link (a pre-filled text is a query value), and the URL encoding guide.

Frequently asked questions

How do I parse a query string?

Paste the URL or the part after the question mark and choose Parse. Each key and value is decoded and shown in a table and as JSON.

How do I build a query string with special characters?

Choose Build, write key=value lines, and the tool encodes each key and value so that spaces, & and = inside values are safe.

What happens with repeated keys?

They are listed in the table and become an array in the JSON. How your code reads them depends on the language.

Should a space be + or %20 in a query string?

Both are read as a space in form data. %20 also works in paths and everywhere else, so it is the safer choice.

Is there a length limit for a query string?

The standard sets none, but browsers, servers and CDNs often limit the whole URL to 2,000 to 8,000 characters. Keep URLs under about 2,000 characters.