Why query strings exist
They let a single URL or page carry variable data without needing a separate page for every possible state. Search results, filters, pagination, tracking, and API requests all rely on this to pass parameters through the URL rather than requiring the server to guess. It is also why bookmarking or sharing a specific filtered view works, since that state lives directly in the URL itself.
Building one by hand
To construct a query string, join each key=value pair with "&", percent-encode any special characters within each key or value first, then prepend "?" before appending the whole thing to a base URL. Getting the encoding step right is the most common source of a broken link, especially with spaces or non-ASCII text.
Frequently Asked Questions
Is a query string visible, and is it secure?
It is fully visible in the browser address bar, browser history, server logs, and often in the "Referer" header sent to other sites. It should never be used to pass sensitive information like a password, and it is not "secure" just because the connection runs over HTTPS.
What is the difference between a query string and a URL path?
The path (like /products/shoes) usually identifies a specific resource in a fairly fixed, hierarchical way. The query string (?color=red&size=10) is meant for optional, variable parameters that filter or modify that resource, avoiding the need for a completely separate path for every possible combination.