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 andgetAll()returns all of them. - Python
parse_qsreturns 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
%2Bfor 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_sourceand 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.