Query String ↔ JSON
Turn a URL’s query string into JSON and JSON into a query string — browser or PHP/Rails/qs bracket rules, chosen by you.
Query String ↔ JSON
Query string or URL
JSON
Paste a URL or query string to see its parameters as JSON, decoded exactly as a browser does.
How is this calculated?
Decoding: application/x-www-form-urlencoded parsing, WHATWG URL Standard (URLSearchParams) — “+” is a space, %XX is UTF-8.
Encoding: the same serializer; spaces as + (forms) or %20 (RFC 3986), as you choose.Runs in your browser — nothing you enter leaves this device.
About this tool
What it does
The part of a URL after the “?” — q=masala+chai&page=2 — carries parameters as names and values. This tool reads a pasted URL or query string into JSON so you can see exactly what a server receives, and builds a correctly encoded query string from a JSON object. Two conventions exist and they disagree, so you choose: the flat rules browsers, fetch and HTML forms use, where a repeated name becomes a list; or the bracket rules of PHP, Rails and Node’s qs, where user[name]=Asha nests an object and tags[]=a builds a list. Decoding follows the WHATWG URL standard to the character, the same code path a browser uses.
How to use it
- Choose Query → JSON or JSON → Query, and the dialect your server speaks.
- Paste a full URL, a query string with or without its “?”, or a JSON object.
- Read the result. Anything a query string cannot hold exactly — a null, an empty list, a number that will arrive as text — is listed beneath it.
- Copy the result, or switch direction to convert it back.
Limits and your data
- A query string holds only text. Values stay text unless you turn on reading numbers, true/false and null — and even then 007, 1e3 and integers too large for JavaScript stay text, so nothing is changed by rounding.
- In the bracket dialect, the same plain key given twice (a=1&a=2) is refused: PHP keeps the last value and qs makes a list, so there is no single right answer. Use a[]= for a list.
- Keys used in two incompatible ways — a=1 together with a[b]=2, or an index that skips ahead such as a[2] before a[0] — are refused with the key named, rather than silently resolved.
- An empty list or object cannot be written in a query string and is left out, with a note. null is written as an empty value, the same as "".
- Up to 1 MB of input; real servers refuse URLs far shorter than that.
- Everything runs in your browser. URLs often carry tokens and personal details; nothing you paste is uploaded, stored or logged, and no request is made to the address you paste.
Questions
Why is "+" turned into a space?
Because that is what the form encoding used by query strings means. A literal plus sign is sent as %2B. If you build a URL by hand and type “+” meaning plus, the server reads a space — encoding the value with this tool avoids that.
Which dialect does my server use?
If it is written in PHP, Ruby on Rails, or Node with Express (which uses qs), it understands brackets. Most other frameworks — and URLSearchParams in the browser — use the flat rules, where only repeating a name makes a list. When unsure, flat is the safe form: every server reads it the same way.
Should spaces be + or %20?
Both decode to a space in a query string. + is what browsers write for forms; %20 is the general URL escape from RFC 3986 and is required in the path part of a URL. Pick whatever the API documentation shows.
Why did 007 stay a string when I asked for numbers?
Reading it as the number 7 would lose the leading zeros, which matter for PIN codes, account numbers and IDs. Only values that convert to a number and back without any change are read as numbers.