Query strings
Last updated 17 June 2026 3 min
A query string is the part of a URL that carries extra information to a web server, typically to filter, track, or modify what the page displays. It's the section that appears after the question mark (?).
Anatomy of a query string
Take this example:
https://example.com/products?category=shoes&color=black&size=10
Breaking it down:
?— marks the start of the query stringcategory=shoes— a key-value pair (parameter)&— separates multiple parameterscolor=blackandsize=10— additional parameters
Each parameter has a key (the name, e.g. category) and a value (e.g. shoes). The server reads these and responds accordingly — in this case, showing black shoes in size 10.
Query string uses
Filtering and sorting — E-commerce sites use query strings to narrow product listings (?brand=nike&sort=price-asc).
Search queries — When you search Google, your term appears as ?q=your+search.
Tracking campaigns — UTM parameters (?utm_source=newsletter&utm_medium=email) tell analytics tools where traffic came from without changing the page itself.
Pagination — ?page=2 loads the next set of results.
Session and user state — Some sites pass IDs or tokens through the URL, though cookies and headers are generally preferred for sensitive data.
Encoding rules
Query strings can only contain certain characters safely. Spaces become %20 (or +), and symbols like &, =, ?, and # must be percent-encoded if used as values. For example, the search "fish & chips" becomes ?q=fish%20%26%20chips.
Most programming languages and frameworks handle this encoding automatically — encodeURIComponent() in JavaScript, urlencode() in PHP, etc.
SEO impact
Query strings can create challenges for search engines:
- Duplicate content —
/shoes?color=blackand/shoes?size=10&color=blackmay show similar pages with different URLs, splitting ranking signals. - Crawl budget waste — Faceted navigation can generate thousands of parameter combinations on a large site, eating into how much search engines crawl your real pages.
- Tracking parameters — UTMs don't change page content, so the same page can be indexed under multiple URLs.
Common fixes include using canonical tags to point parameter variants back to a clean URL, configuring parameter handling rules where appropriate, and blocking unhelpful parameter combinations in robots.txt when crawl budget is a concern.
Query strings vs fragments
Though similar at a glance, query strings (?) and fragments (#) are not the same. The fragment points to a section within a page and is never sent to the server — it is purely client-side. Query strings are sent with the request and processed server-side.
https://example.com/page?id=10#section-3
Query string = ?id=10
Fragment = #section-3
Quick reference
| Component | Symbol | Purpose |
|---|---|---|
| Start | ? |
Begins the query string |
| Separator | & |
Joins multiple parameters |
| Assignment | = |
Links key to value |
| Encoding | %XX |
Represents special characters |
| Fragment | # |
Page section (not part of query) |
Use query strings correctly
Query strings are a simple but powerful way to pass data through URLs. They provide filtering, search, tracking, and pagination across the web. Used well, they make sites more flexible; used carelessly, they can fragment SEO performance and bloat what search engines have to crawl.
Disclaimer: All information contained herein is for informational purposes only. It is not advice or instructional.