What is a Query string?
https://example.com/search?q=coffee+beans&sort=price&page=2
How a query string is built.
A question mark starts the query string. Each parameter is written name=value, and parameters are separated by &. The query string ends where the fragment, the part after #, begins.
A name can appear more than once, as in tag=red&tag=blue. Servers decide how to read repeated names, and most treat them as a list.
Characters that need escaping.
Characters with a special meaning, such as & = ? # and spaces, must be percent-encoded inside names and values, for example %26 for & and %20 for a space. In a query string a space may also be written as +.
Forgetting to encode a value is the most common reason a link silently loses part of its parameters. The query string builder and the URL encoder do it for you.
What query strings carry.
Search terms
?q=coffee
Filters and sorting
?color=blue&sort=price
Pagination
?page=2
Tracking tags
?utm_source=newsletter
Session or state
?step=3&ref=home
API requests
?fields=name,email&limit=20
Common questions
What is the difference between a query string and a fragment? +
The query string is sent to the server and can change what is returned. The fragment, after #, stays in the browser and only scrolls or highlights something on the page.
Is there a length limit? +
The standard doesn't set one, but browsers, servers and proxies do. Keeping a full URL under about 2,000 characters is a safe practical limit.
Do query parameters affect SEO? +
Pages that differ only by parameters can be treated as duplicates. A canonical tag pointing to the preferred URL tells search engines which one to use.
How do I read the parameters of a URL? +
Paste it into the URL parser, which lists every parameter with its decoded value.