Q

Query String

Development 3 min read Entry 50 of 78
Definition

A query string is the part of a URL after the question mark, used to pass extra information to the page.

In plain English

In a shop address with a question mark followed by colour and size values, everything after the mark is the query string. It is a list of name and value pairs joined together.

The page reads those values and changes what it shows, filtering products, remembering a campaign source, jumping to page three of the results.

Why it matters

Query strings are everywhere once you notice them: search results, product filters, pagination, campaign tracking, payment returns.

They also cause real problems, duplicate content when the same page exists at five addresses, and cache misses that slow a site down. Knowing what they are makes both diagnosable.

How it works

  1. A question mark starts itEverything before it is the path.
  2. Pairs are joined togetherEach is a key and a value, in any order.
  3. The page reads themAnd responds accordingly.
  4. Special characters get encodedA space becomes a percent code or a plus sign.

Nothing private goes in an address

Query strings are stored in many places along the way. Secrets and personal data belong in a request body instead.