Skip to content

Query Parameters vs Path Parameters

Filters in the query string versus identity in the path—compare URL design for APIs, caching, and analytics.

Overview

URL design decides what is a thing and what is a view of that thing. Paths should name resources, so /tools/json-formatter is a page you can link and index. Query strings should refine a collection, so ?category=json&sort=new stays flexible without minting a new canonical URL for every combination of filters.

Query parameters

Open Query String Parser

Pros

  • Optional and order-independent by nature
  • Perfect for filters, sorting, and pagination
  • Easy to add without breaking existing links

Cons

  • Parameter explosion creates duplicate URLs
  • Needs canonical tags to protect indexing

Path parameters

Pros

  • Expresses hierarchy and identity clearly
  • Cleaner canonical URLs for sharing
  • Simple to route and cache per resource

Cons

  • Poor fit for optional combinations
  • Changing structure breaks old links

Comparison table

AspectQuery parametersPath parameters
ExpressesRefinement of a collectionIdentity of a resource
CardinalityCombinatorialOne URL per resource
SEO handlingCanonicalise carefullyNaturally canonical
Best fitThe value is an optional filter or view settingThe value identifies a specific resource

Recommendation

Put identity in the path and refinements in the query string, then decide explicitly which parameter combinations are indexable. Parse and rebuild query strings with proper encoding rather than string concatenation.

Related tools

Related articles

Frequently asked questions

Should filter URLs be indexable?
Usually only a curated few. Point the rest at a canonical version so crawlers do not spend budget on near-duplicate parameter permutations.
Does parameter order matter?
Not to servers, but it does to caches and analytics, which treat different orderings as different URLs. Normalise the order when you generate links.
What pushes someone toward Query parameters instead of Path parameters?
Query parameters wins when the value is an optional filter or view setting. The practical upside is that optional and order-independent by nature, and perfect for filters, sorting, and pagination. The trade-off to watch is that parameter explosion creates duplicate URLs.
When does Path parameters beat Query parameters for the same job?
Reach for Path parameters when the value identifies a specific resource. It gives you expresses hierarchy and identity clearly plus cleaner canonical URLs for sharing, at the cost that poor fit for optional combinations.
Can ToolHub help me try Query parameters and Path parameters before I commit?
Yes. The tools linked from each side of Query Parameters vs Path Parameters run in your browser, so you can exercise Query parameters and Path parameters with sample data without uploading anything.