Query String ↔ JSON
Convert a URL query string to JSON and JSON back to an encoded query string, with repeated keys, bracket notation, arrays and nested objects. Browser only.
How to use Query String ↔ JSON
- 1Choose a direction, then paste a URL or query string, or a JSON object.
- 2Set how keys are read or written: bracket notation, plain keys, array style and encoding.
- 3Copy the result, or use it as input to convert back the other way.
What makes it better
- Accepts a full URL, a leading ?, or bare key=value pairs
- Repeated keys become arrays; a[b]=1 and a[]=1 become nested data
- Origin, path, query and hash are shown separately for a pasted URL
- Array and nested styles when building: repeated keys, a[] or a[0], brackets or dots
- Skips __proto__, constructor and prototype keys and says so
About Query String ↔ JSON
Query String ↔ JSON parses a full URL, ?a=1&b=2 or a=1&b=2 into JSON, and turns a JSON object back into a correctly encoded query string. Repeated keys become arrays, and bracket notation such as filter[brand]=acme becomes nested objects. Keys that could pollute JavaScript prototypes are skipped and reported.
Common uses
- Read what a long tracking or search URL actually sends to the server.
- Build the query for an API request from a JSON object in a test case.
- Check how a framework will see ?filter[status]=open&filter[tag]=bug.
- Debug a malformed percent-encoded parameter without losing the raw text.
Example
Input
https://example.com/search?q=running+shoes&tag=a&tag=b&filter[brand]=acme&filter[size]=9#results
Result
{
"q": "running shoes",
"tag": [
"a",
"b"
],
"filter": {
"brand": "acme",
"size": "9"
}
}Good to know
- Values stay strings unless you turn on Detect numbers and booleans, because a query string has no types. Long digit strings and leading zeros are kept as text.
- There is no single standard for arrays and nesting in query strings. Servers differ, so pick the style your backend expects.
- Malformed percent-encoding such as %E0%A4%A is reported and the raw text is kept. A key whose shape conflicts with an earlier key is skipped with a notice.
Query String ↔ JSON FAQ
Why are the numbers in the JSON shown as strings?
A query string is plain text, so the converter cannot know whether page=2 meant a number. Turn on Detect numbers and booleans to convert exact forms such as 2, 1.5, true and false; values like 007 or a very long ID stay text.
What is the difference between bracket notation and plain keys?
With bracket notation, a[b]=1 becomes {"a":{"b":"1"}} and a[]=1 adds to an array. With plain keys, the text a[b] is kept as a single literal key, which matches how browsers' URLSearchParams reads it.
Why were some of my keys skipped?
Keys named __proto__, constructor or prototype can be used to tamper with JavaScript objects, so the parser refuses them wherever they appear in a key path. The page lists the skipped keys; the other parameters are processed as normal.
Does a plus sign mean a space?
In form-style query strings yes, and + means space by default here. Percent-encoded %2B is always a real plus. Turn off + means space if your values contain literal plus signs, such as phone numbers or base64.
How do I choose between repeated keys, a[] and a[0] for arrays?
Repeated keys (tag=a&tag=b) are the most widely understood. The a[] style is common in PHP and Rails, and a[0] indexed keys are used by qs and some JavaScript frameworks. Arrays of objects always use indexes so the fields stay grouped.