Are URL Query Parameters Case Sensitive?

Learn why query parameter names can be case-sensitive, how they differ from domains and paths, and how to test clients, servers, and caches.

Published
Reading time
6 min read
Are URL Query Parameters Case Sensitive?
On this page

Are URL query parameters case sensitive? They can be. A request containing pageSize=10 may behave differently from one containing pagesize=10 because the application receiving the request decides how to interpret parameter names.

This guide explains the distinction between query names, domains, and paths, then shows how to reproduce and diagnose capitalization mismatches.

Key Takeaways

  • Domain names are case-insensitive, but that rule does not automatically apply to paths or query parameters.
  • A server framework, application, or API contract determines whether pageSize and pagesize have the same meaning.
  • The same request can pass through clients, proxies, caches, and application code that handle query strings differently.
  • Document the exact spelling of each parameter and test the behavior of the complete deployed request path.

Domain, path, and query case are separate questions

Consider these URLs:

https://EXAMPLE.com/Items?pageSize=10
https://example.com/items?pagesize=10

The hostnames differ only in letter case and identify the same DNS name. The paths and query names are separate components, however, so that hostname rule does not make the two requests equivalent.

ComponentExampleCase behavior
Domain nameEXAMPLE.com vs. example.comDomain names are case-insensitive.
Path/Items vs. /itemsThe server, application, and underlying routing or storage rules determine whether they reach the same resource.
Query parameter namepageSize vs. pagesizeInterpretation depends on the application and its query-parsing conventions.

URL syntax provides a query component, but it does not require every query to use name=value pairs or give those pairs one universal case-matching rule. Even when an API uses that familiar format, its documentation and implementation determine what a name means.

Advertisement

See the difference in a local API

The following illustrative server uses Node.js's built-in URL and URLSearchParams APIs. It recognizes only the exact parameter name pageSize; other names are ignored. It also rejects repeated pageSize entries rather than silently choosing one.

Save this as server.js and run it with node server.js using Node.js 18 or later:

const http = require('node:http');

const server = http.createServer((req, res) => {
  const url = new URL(req.url, 'http://localhost');

  if (req.method !== 'GET' || url.pathname !== '/items') {
    res.writeHead(404, { 'content-type': 'application/json' });
    res.end(JSON.stringify({ error: 'Not found' }));
    return;
  }

  const values = url.searchParams.getAll('pageSize');
  if (values.length > 1) {
    res.writeHead(400, { 'content-type': 'application/json' });
    res.end(JSON.stringify({ error: 'Duplicate pageSize' }));
    return;
  }

  res.writeHead(200, { 'content-type': 'application/json' });
  res.end(JSON.stringify({ pageSize: values[0] ?? null }));
});

server.listen(3000, '127.0.0.1', () => {
  console.log('Listening on http://127.0.0.1:3000');
});

In another terminal, send requests with differently capitalized names:

curl 'http://127.0.0.1:3000/items?pageSize=10'
curl 'http://127.0.0.1:3000/items?pagesize=10'
curl 'http://127.0.0.1:3000/items?PAGESIZE=10'
curl 'http://127.0.0.1:3000/items?pageSize=10&pageSize=20'

The expected response bodies, in order, are:

{"pageSize":"10"}
{"pageSize":null}
{"pageSize":null}
{"error":"Duplicate pageSize"}

The final response has HTTP status 400; the others have status 200. Stop the server with Ctrl+C. The example illustrates one application policy, not a rule for all APIs. Another application could deliberately treat these names as equivalent, reject unknown names, or use a default value when the documented name is absent.

URLSearchParams interprets the query as form-style name/value pairs and decodes them. For example, page%53ize is read as pageSize, while pagesize remains a different name. Percent-encoding and case normalization are different operations. Parameter values can have their own case rules too; don't assume that a case-insensitive name implies a case-insensitive value.

Diagnose an inconsistent request

  1. Check the contract. Find the exact spelling in the API's documentation, OpenAPI definition, or server code. Check whether unknown parameters are ignored or rejected and how duplicates are handled.
  2. Compare the requests sent by each client. Capture the request URL in a safe test environment. Compare capitalization, encoding, repeated names, and values—not just the parameters shown in a user interface. Use fictional values; query strings can appear in logs and other records.
  3. Test one change at a time. Send the documented spelling, a lowercase variant, and an uppercase variant with the same value. Compare both HTTP status and response body. A successful status alone does not prove the parameter was honored.
  4. Check the server framework and application. Inspect how the deployed framework parses query strings and how application code looks up names. Confirm behavior for the version and configuration in use; a framework may expose parsed data differently from the raw request target.
  5. Test through the deployed intermediaries. A proxy or cache may forward, normalize, omit, or include query strings in its cache key according to its configuration. Compare an approved direct-to-origin test with the normal route, and inspect cache-status headers or logs where available. Do not assume a cache treats differently capitalized queries as either identical or distinct.

Advertisement

Document and test the contract

For each query parameter, publish its exact name, value format, whether it is required, its default, and the behavior for unknown or repeated names. State explicitly if names are case-insensitive, and specify what happens if a request contains both pageSize and pagesize.

Add client and integration tests for the documented spelling and relevant variants. Include duplicate names, empty values, encoded names, and requests through the actual proxy and cache configuration. If the API intentionally accepts case variants, define a canonical spelling and a conflict policy—for example, reject ambiguous requests rather than letting different components select different values.

Coordinate normalization with cache-key construction and authorization. If an intermediary treats two requests as equivalent while the application treats them differently, the wrong response could be reused. Conversely, treating equivalent application requests as separate cache entries can reduce cache reuse. Test these decisions with non-sensitive data before deployment.

Common Mistakes

  • Applying the domain rule to the whole URL. A case-insensitive hostname says nothing by itself about the application's path or query-name matching.
  • Assuming all frameworks behave alike. Verify the parser and lookup behavior actually used by the deployed application.
  • Treating a 200 response as proof of a match. An API may ignore an unrecognized parameter and return a default result.
  • Ignoring duplicates and mixed-case collisions. pageSize=10&pagesize=20 can be ambiguous if a component folds case while another does not.
  • Changing cache normalization without checking the origin. The cache and application must agree on which requests are equivalent.

Conclusion

Use the parameter spelling specified by the API, and verify how the complete request path handles alternatives. Case behavior is an application contract, not a consequence of domain-name matching.

Research and execution note: Current standards, framework documentation, and cache documentation were not retrieved for this article, and the example was not executed here. Check the documentation and test results for your deployed versions before relying on their behavior.

What would your domain sell for?

A free TidyURLs account unlocks the Domain Estimator. It prices a name from 191,011 real domain sales.