Format Code Now
/
Web & markupQuery String to JSON Next: REM to PX Converter ›

Query String to JSON Converter

WM-03

Paste a query string or a whole URL to get its parameters as a JSON object. Switch to JSON to query string to build a ?name=value&... string from JSON.

Runs in your browser. Nothing is uploaded.

Query string, URL or JSON

Result

How to use it

  1. Paste a query string such as ?a=1&b=2, or a full URL, into the input box.
  2. Choose Query string to JSON. Pick whether repeated keys become arrays and whether + counts as a space.
  3. To go the other way, paste a JSON object and choose JSON to query string. Pick the array style and the space style.
  4. Set the indent for the JSON, then copy the result or download it.
  5. Use Share link to keep the input and settings in a link.

From query string to JSON

The text after the ? is split on &, then each piece on its first =, and both sides are percent-decoded. With Repeated keys become arrays on, tag=a&tag=b gives "tag": ["a", "b"], and a key written as tag[] is also an array, even with one value. With it off, the last value wins and earlier ones are dropped. Every value stays a string, so 007 is not turned into 7 and true is not turned into a boolean.

From JSON to query string

Strings, numbers, booleans and null become name=value pairs. Spaces become %20, or + if you tick Encode space as +. A null becomes an empty value. A nested object such as {"a":{"b":1}} becomes a[b]=1, with the brackets encoded as %5B and %5D. A list of plain values repeats the key, or uses a[] if you pick the bracket style. Big numbers are copied exactly as you wrote them.

Plus signs, fragments and order

A + in a query string means a space only in form-style data, so the decode option is on by default and can be turned off. Anything after a # is treated as the fragment and ignored. Keys keep the order they have in the input, including keys that look like numbers. An input without any = signs, such as just flag, gives "flag": "".

Error messages and what to do

MessageWhat it meansFix
No parameters found. A query string looks like name=Ada&city=London.The input has no name and value pairs after the ? and before any #.Paste the query part of a URL, such as ?a=1&b=2.
Invalid percent-encoding in "a=%E0%A4%A". A % must be followed by two hex digits and the bytes must be valid UTF-8.A % code is cut short, or the bytes it makes are not valid text.Fix or remove the broken code. Encode a literal percent sign as %25.
The JSON must be an object, for example {"name":"Ada","tags":["a","b"]}.JSON to query string needs an object at the top level, not an array or a single value.Wrap your data in an object with named keys.
The object has no values to put in a query string.The object is empty or only holds empty objects and arrays.Add at least one key with a value.

Questions people ask

How do I convert a query string to JSON?

Paste the query string, or the whole URL, and choose Query string to JSON. Each name becomes a key and each decoded value a string. It all runs in your browser. Then copy the JSON or download it as a file.

How are repeated parameters handled?

With Repeated keys become arrays ticked, a name that appears twice, like tag=a&tag=b, gives an array of both values. A name ending in [] always gives an array. With the option off, only the last value is kept.

Does it convert numbers and true or false?

No. Every value stays a string, so id=007 gives "007". A query string has no types, and guessing them would change data such as IDs with leading zeros. Convert the fields you need after you copy the JSON.

How do I turn JSON into URL parameters?

Paste a JSON object and choose JSON to query string. Keys become names and values are percent-encoded. Nested objects use a[b]=1 and lists repeat the key, or use a[] if you choose the bracket style. The brackets are percent-encoded as %5B and %5D in the output.

Should I encode spaces as + or %20?

Both decode to a space in a query string, and %20 works everywhere, including in the path. Use + only when the receiving system expects form-style data. The default here is %20.

Can it handle nested keys like user[name]=Ada?

A key with brackets in the middle is kept as written, so the JSON key is "user[name]". Only a trailing [] is turned into an array. Building nested objects from bracket keys depends on the framework, and this tool does not guess.

About this tool

Accepts a bare query string, one that starts with ?, or a full URL; anything after # is ignored. Every value stays text, so 007 and true are not converted. Keys keep the order they appear in. With the array option off, the last value of a repeated key wins and the earlier ones are dropped. Brackets in a key such as a[b] are kept as part of the key; only a trailing [] is turned into an array. Going the other way, nested objects become a[b]=1 (with the brackets percent-encoded as %5B and %5D) and null becomes an empty value. Large numbers are copied exactly as written.

Format Code Now: free, no ads, no accounts. Your input stays in your browser.