Skip to main content
CalcChef

Query String to JSON

Paste a query string or a full URL to get JSON: repeated keys and key[] become arrays, + and %20 decode to spaces, with optional nesting and number types. How it works

Use the Query String to JSON

Paste a query string, one starting with ?, or a whole address (the part after the first ? is read and the #fragment is dropped). Up to 1,000,000 characters. A + and %20 both decode to a space, %2B to a plus sign. Pairs are split on & only. A key that repeats, or ends in [], becomes an array. Names in brackets such as a[b] stay one flat key unless you tick the box below.

6 pairs read, 5 keys in the JSON.

About the Query String to JSON

The query string name=John+Doe&age=30&tag=red&tag=blue becomes {"name":"John Doe","age":"30","tag":["red","blue"]}: a + is a space, a key that repeats becomes an array, and every value stays a string. Paste a bare query string or a whole URL; the converter reads the part after the first ? and drops the #fragment.

Query strings and the JSON they give

Query stringJSON (written on one line)
name=John+Doe&age=30&city=New%20York&tag=red&tag=blue&colors[]=green{"name":"John Doe","age":"30","city":"New York","tag":["red","blue"],"colors":["green"]}
https://example.com/search?q=cron+job&page=2#results{"q":"cron job","page":"2"}
a[b]=1&a[c]=2{"a[b]":"1","a[c]":"2"}
a=1&a[]=2{"a":["1","2"]}
a=1;b=2{"a":"1;b=2"}
x=%E2%82%AC&y=%2B1{"x":"€","y":"+1"}
__proto__=x&constructor=y{"__proto__":"x","constructor":"y"}

The first row is the text the page opens with: 6 pairs and 5 keys. With both boxes unticked, brackets with a name inside are not nested, and a semicolon never separates pairs.

With Nest bracket keys or Infer numbers and booleans ticked

Query stringBox tickedJSON (written on one line)
a[b]=1&a[c]=2Nest{"a":{"b":"1","c":"2"}}
a[b][c]=1Nest{"a":{"b":{"c":"1"}}}
a[0]=x&a[1]=yNest{"a":["x","y"]}
a=1&a[b]=2Nest{"a":"1","a[b]":"2"}
name=John+Doe&age=30&tag=red&tag=blueInfer{"name":"John Doe","age":30,"tag":["red","blue"]}
n=-4&x=2.5&ok=trueInfer{"n":-4,"x":2.5,"ok":true}
zip=007&p=1.50&e=1e3&T=TrueInfer{"zip":"007","p":"1.50","e":"1e3","T":"True"}

a=1&a[b]=2 clashes (a cannot be both a string and an object), so a[b] stays a flat key and a note says so. Infer converts only text that is already the plain form of a number, and only the lowercase words true and false.

Frequently asked questions

How do I convert a URL query string to JSON?
Paste the query string, or the whole URL, into the box; the JSON updates as you type. https://example.com/search?q=cron+job&page=2#results gives {"q":"cron job","page":"2"}, with notes that the part after the first ? was read and the fragment dropped.
Does a[b]=1 become a nested object?
Only when you tick Nest bracket keys. Unticked, a name inside the brackets stays one flat key, so a[b]=1&a[c]=2 gives {"a[b]":"1","a[c]":"2"}, and only empty brackets at the end make an array: a=1&a[]=2 gives {"a":["1","2"]}. Ticked, a[b]=1&a[c]=2 gives {"a":{"b":"1","c":"2"}} and a[0]=x&a[1]=y gives {"a":["x","y"]}. Nesting stops at 10 levels.
Why are numbers in quotes in the JSON?
A query string carries only text, so age=30 gives "30", a string. Tick Infer numbers and booleans to write age=30 as 30 and ok=true as true. Text that would change if written as a number, such as 007 or 1.50, stays a string, because a ZIP code or a price is not always a number.
Is + a space or a plus sign in a query string?
A space. + and %20 both decode to a space, as the WHATWG URL Standard’s form parser reads them. Write %2B for a literal plus: y=%2B1 gives "+1".
What happens to a broken percent sign?
p=100% keeps the % as typed and adds a note. An escape that is not valid UTF-8, such as %FF, becomes U+FFFD (�), also with a note.

Related Tools

View all tools