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

Common questions

What is the difference between a query string and a URL fragment?
The query string comes after the ? and is sent to the server; the fragment comes after the # and stays in the browser, typically used to scroll to a section or drive client-side routing.
Do query strings hurt SEO?
They can, if many parameter combinations produce duplicate or near-duplicate pages. Canonical tags, careful parameter handling, and clean shareable URLs help search engines consolidate ranking signals.
How long can a query string be?
There is no fixed limit in the spec, but browsers and servers impose practical caps around 2,000 to 8,000 characters. Very long query strings risk being truncated, so keep them lean.

Related tools

Related terms for Query String