Query String to JSON Converter
Paste a full URL or just the part after the question mark to see it as JSON. Or paste JSON to get an encoded query string, with a choice of how lists are written.
Worked examples
Query to JSON
?q=shoes&size=9&size=10&filter[colour]=red
{ "q": "shoes", "size": [ "9", "10" ], "filter": { "colour": "red" } }
The repeated size became a list and the bracket became a nested object.
JSON to query
{"q": "a b&c", "n": 2, "l": [1, 2]}
q=a%20b%26c&n=2&l=1&l=2
Spaces and ampersands are percent encoded.
About Query String to JSON Converter
A query string packs values into a URL as name=value pairs joined with ampersands, with special characters written as percent codes. When a name appears twice the values form a list, and many frameworks read square brackets as nesting, so filter[colour]=red becomes an object and tags[]=a&tags[]=b becomes a list. Reading a long one by eye, or building one with nested filters, is slow and error prone.
Paste a full URL or just the part after the question mark and see the data as JSON. Percent codes and plus signs are decoded, repeated names are gathered into lists, bracket syntax is read as nested data if you ask for it, and plain digits and true or false can become real JSON values. In the other direction a JSON object is encoded with the list style you choose, so you can match what a particular server or framework expects. A broken percent code is reported with the number of the pair it is in.
How to use Query String to JSON Converter
- Choose query string to JSON, or JSON to query string.
- Paste a URL, a query string or a JSON object.
- Set the options: nested brackets and value types when reading, or the list style when building.
- Copy the result.
Common uses
- Reading the parameters of a long tracking or search URL
- Building a query string for a test request
- Checking how a framework will read repeated keys
- Comparing two URLs by their parameters
Frequently asked questions
How are repeated names handled?
When a name appears more than once its values are gathered into a list, in the order they appear.
What does the bracket option do?
With it on, a[b]=1 becomes {"a": {"b": "1"}} and a[]=1&a[]=2 becomes a list. With it off, the brackets are kept as part of the name.
Does a plus sign mean a space?
In a query string made by a form, yes, and the parser reads it that way. A real plus sign is written as %2B.
Which list style should I choose?
It depends on the server. Repeating the name is the most common, brackets are used by PHP and Rails style frameworks, indexes by some others, and commas are shorter but need a server that splits on them.
Are values changed to numbers?
Only if you ask. Even then, a value with a leading zero such as 007 stays as text so codes and postcodes keep their zeros.