DevKit
Converter

Query String ↔ JSON

Convert between URL query strings and JSON objects.

Last updated: August 2026

Share:

Was this tool helpful?

Query strings as objects

A URL query string packs key-value pairs after the ?, separated by &. Turning it into a JSON object makes it easy to inspect or build in code, and the reverse lets you assemble a query from structured data. The subtleties are all in how edge cases, repeats, nesting, and encoding, get handled.

Example

Query string:

?name=Ada&role=dev&role=lead&active=true

As JSON:

{
  "name": "Ada",
  "role": ["dev", "lead"],
  "active": "true"
}

Repeated keys and types

The same key twice is the ambiguous part. Here role appears twice and collapses into an array, but some parsers keep only the last value instead. There is no single standard, so check which behavior your tool uses. Also note everything is a string, active is "true", not a boolean, because query strings carry no types.

Encoding is part of the job

Values are percent-encoded in the URL, so %20 is a space and %26 is a literal ampersand that is not a separator. A correct converter decodes on the way in and re-encodes on the way out, otherwise a value containing & silently splits into two keys. For the raw encoding mechanics, see the URL encoder.

FAQ

How is a key with no value treated? Something like ?flag usually becomes an empty string or null, depending on the parser, so do not rely on it being a boolean true.

Can I nest objects in a query string? Only through conventions like a[b]=1, which some libraries expand into nested JSON and others leave as a literal key. It is not part of the core spec.