How to use JSON to query string
- Paste a JSON object into JSON object. Syntax errors are reported with their line and column.
- Choose Arrays as:
items[0]=a&items[1]=b,items[]=a&items[]=b,items=a&items=boritems=a,b. - Tick Percent-encode [ and ] if your target is strict about brackets.
- Copy the Query string, and use the Key / Value table to check each parameter before encoding.
What it does and when to use it
APIs and search pages often take filters as query parameters: ?filters[size][]=42&page=2. Writing those by hand from a JSON body is slow and easy to get wrong, especially the escaping. Use this tool to build test URLs from a request payload or to check what a client library such as qs should send.
For flat key–value pairs typed one by one, the query string builder is simpler. To encode a single value, use the URL encoder. To read an existing URL back into its parts, use the URL parser.
How it works
The JSON is parsed, then walked depth-first, keeping key order:
- An object key nested under a parent becomes
parent[key]. - An array element becomes
key[0],key[], a repeatedkey, or part of one comma-joined value, depending on the option. - A primitive becomes a pair;
nullgives an empty value.
Each key and value is then encoded with encodeURIComponent, which follows the RFC 3986 rules. Brackets in keys are put back as [ and ] unless you tick the option. Spaces become %20, not +. Pairs are joined with & and no leading ?. It all runs in your browser.
Worked examples
The default input, arrays as indexes:
{ "q": "running shoes", "page": 2, "filters": { "size": [42, 43], "color": "red" }, "inStock": true }
q=running%20shoes&page=2&filters[size][0]=42&filters[size][1]=43&filters[color]=red&inStock=true
The same input with Arrays as items=a,b and brackets encoded:
q=running%20shoes&page=2&filters%5Bsize%5D=42%2C43&filters%5Bcolor%5D=red&inStock=true
The comma inside the value is encoded too, as %2C.
An array of objects plus special characters, with the repeated-key option:
items[0][id]=1&items[0][qty]=2¬e=50%25%20off%20%26%20free
The objects keep their index, and % and & in the note are escaped.
Limits and tips
- Empty arrays and objects vanish.
{"tags":[]}produces no parameter at all, so the server cannot tell “empty” from “missing”. - No types survive.
"2"and2give the same text. Parse numbers and booleans on the server. - Long URLs. Big objects can produce URLs that some servers, proxies or browsers refuse. Send large filters in a POST body instead.
Frequently asked questions
Which array style should I choose?
Why are [ and ] not encoded by default?
What happens to null, true and numbers?
Why do arrays of objects ignore the Comma or Repeated option?
Can I paste an array or a single value?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.