What is a query string?
Short answer
A query string is the portion of a URL after the ? that passes data as key=value pairs joined by &. For example ?page=2&sort=new sends two parameters: page and sort.
Where the query string sits
In a URL, the query string starts at the ? and runs to the end (or to a # fragment). It carries parameters the page or API uses. See the anatomy of a URL for the full structure.
https://example.com/search?q=cats&page=2
|________________|
query stringHow it is structured
- A
?marks the start of the query string - Each parameter is a
key=valuepair - Pairs are separated by
& - Values with spaces or symbols are percent-encoded (a space becomes %20)
- The same key can repeat, e.g.
?tag=a&tag=b
What query strings are used for
- Search terms, filters, sorting, and pagination
- Tracking parameters like UTM tags
- Passing non-sensitive state between pages
- API request options