What is Query String?

A query string is the part of a URL after the question mark that passes key-value parameters to a page, used for search, filtering, and tracking.

A query string is the portion of a URL that follows the question mark and carries data to the server or page as a set of key-value pairs. Each pair is written as key=value, and pairs are joined with ampersands. For example, in example.com/search?q=shoes&sort=price, the query string is q=shoes&sort=price, telling the page to search for shoes sorted by price.

Query strings power a huge range of web functionality. Search boxes append the query, e-commerce filters encode selected facets, pagination stores the current page number, and analytics platforms read tracking parameters. Because the values are visible and editable in the address bar, query strings make application state shareable — you can copy a filtered results URL and send it to a colleague.

Values in a query string must be URL-encoded so that reserved characters do not break the structure. A search term containing an ampersand or space has to be percent-encoded, otherwise the server may interpret it as a parameter separator and lose part of the value. This is why building and parsing query strings correctly matters for both functionality and analytics accuracy.

For marketers, the query string is where UTM parameters live, making it central to campaign attribution. Understanding how to build a clean query string, parse one to see what data a link is passing, and strip unnecessary tracking parameters for a tidy shareable link are core skills. Overly long or duplicated parameters can also create SEO issues by generating many URLs for the same content.

Examples

  • ?q=shoes&sort=price&page=2 — search term, sort order, and page number
  • ?utm_source=newsletter&utm_medium=email — campaign tracking parameters
  • ?ids=1,2,3 — a single parameter carrying a comma-separated list

Frequently asked questions

Free tools for working with Query String

Related terms