Skip to content
Dev Utilities

Query params to JSON

Split a query string into structured JSON and back

0 chars
0 chars

Conventions this tool follows

  • A repeated key becomes an array (a=1&a=2 → {"a": ["1", "2"]}) rather than the last value winning, because dropping one of two values that were both sent is the usual way this goes wrong.
  • Brackets nest: a[b]=c gives {"a": {"b": "c"}}, and a[]=1&a[]=2 appends. Numeric brackets that run 0, 1, 2… come back as an array; anything else stays an object with those keys.
  • a= is the empty string and a (no equals sign) is null. They mean different things on the wire, so they stay apart — which is what lets a round trip come back unchanged.
  • Every value is a string. "true" and "0123" are left as text: inferring types would turn a postcode into a number and a version string into a boolean.
  • Going back to a query string, arrays always use the a[]= form even for one element, so the structure survives a round trip. The text may differ from what you pasted; the parsed result will not.
  • + is read as a space (that is what application/x-www-form-urlencoded means) and written as %20, which every server accepts. A literal plus must arrive as %2B.
  • A URL fragment (#results) is dropped: it never reaches the server, so it is not part of the parameters.