JSON to query string — nested objects and arrays to URL parameters

Paste a JSON object and get a percent-encoded URL query string, with nested objects written in bracket notation and arrays in the style your backend expects, plus a table of every key and value.

Live demo · real result from this tool

Query string

q=running%20shoes&page=2&filters[size][0]=42&filters[size][1]=43&filters[color]=red&inStock=true

Table

KeyValue
qrunning shoes
page2
filters[size][0]42
filters[size][1]43
filters[color]red
inStocktrue

Processed on your device — nothing is uploaded.

How to use JSON to query string

  1. Paste a JSON object into JSON object. Syntax errors are reported with their line and column.
  2. Choose Arrays as: items[0]=a&items[1]=b, items[]=a&items[]=b, items=a&items=b or items=a,b.
  3. Tick Percent-encode [ and ] if your target is strict about brackets.
  4. 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 repeated key, or part of one comma-joined value, depending on the option.
  • A primitive becomes a pair; null gives 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&note=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" and 2 give 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?
Match your server. items[]=a&items[]=b is the PHP and Rails convention. items=a&items=b is what URLSearchParams.getAll, Python and Go read as a list. items[0]=a keeps the order explicit, as the qs library does by default. items=a,b needs the server to split on commas itself.
Why are [ and ] not encoded by default?
Most servers and libraries read raw brackets fine, and they keep the URL readable. Strictly, RFC 3986 reserves them for IPv6 hosts, so tick "Percent-encode [ and ]" if a proxy, signer or strict parser rejects them.
What happens to null, true and numbers?
Numbers and booleans become their text form (2, true). null becomes an empty value, so {"a":null} gives a=. Your server will see strings either way.
Why do arrays of objects ignore the Comma or Repeated option?
Objects inside arrays need an index to keep their fields together, so they always use items[0][id] form. Comma style is used only when every element is a plain value.
Can I paste an array or a single value?
No. The top level must be a JSON object, because each top-level key becomes a parameter name. Wrap an array in an object, such as {"ids":[1,2,3]}.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close