Query String to JSON: Tips, Gotchas and Type Traps
The single biggest gotcha converting a query string to JSON is types: every value comes out as a string, so "2" and "true" are text, not a number or boolean — cast them in your own code. Knowing that, plus how repeated keys and + behave, keeps the output predictable.
The converter is faithful to how URLs actually work, which is exactly why a few results surprise people. Here are the practices and traps worth internalizing.
Best practices
- Expect strings, cast later. Treat every value as text and convert numbers, booleans, and dates in your application. The JSON reflects the URL, which has no types.
- Paste the full URL when unsure. You do not need to trim the domain and path — the converter uses only the part after
?, so pasting the whole link avoids accidentally cutting a parameter. - Check array-shaped fields. If a field you expected to be single is an array, a key repeated in the input. Decide whether your code should read the first value or all of them.
- Convert privately. Because it runs locally, use it freely on URLs containing session tokens or IDs — nothing is logged or uploaded.
Gotchas and how they behave
| Input | Output | Why |
|---|---|---|
n=2 | "n": "2" | All values are strings |
ok=true | "ok": "true" | No boolean type in URLs |
a=1&a=2 | "a": ["1","2"] | Repeated key becomes array |
q=a+b | "q": "a b" | + decodes to a space |
x= | "x": "" | Empty value is kept |
Common mistakes
A frequent error is assuming a numeric-looking value is a number and doing math on it directly — you will concatenate strings instead. Another is needing a literal plus sign: in a query string a real + must be encoded as %2B, otherwise it decodes to a space. People also forget that keys are case-sensitive, so Page and page produce two different JSON fields. Finally, if a value contains what looks like nested structure, such as filter=a:1,b:2, the converter keeps it as one string — it does not parse sub-syntax you invented.
Troubleshooting the output
If a value looks wrong, decode it in isolation with a URL decoder to confirm what the original characters were. If a field is unexpectedly an array, search the input for a repeated key. And if the JSON is empty, check that your input actually contained a ? or valid pairs — a bare word with no = has nothing to split. When in doubt, convert a known-good example first to confirm the tool behaves as you expect, then run your real input and compare — the difference usually points straight at the offending parameter.
Try the Query String to JSON converter — free and 100% in your browser.
FAQ
Why is my number a string in the JSON?
Query strings only carry text, so there is no way to know 2 is a number. The converter preserves it as "2"; cast it to a number in your code.
How do I keep a literal plus sign?
Encode it as %2B in the URL. An unencoded + is defined to mean a space and will decode to one.
Why did two parameters merge into an array?
They shared the same key. The converter groups repeated keys into an array so no value is lost — this is expected behavior, not a bug.
Does it parse nested or dotted keys into objects?
No. A key like user.name stays a single flat field named user.name; the tool does not expand dot or bracket notation into nested objects.
Related free tools
- JSON to Query String — go back the other way.
- URL Decoder — check a single decoded value.
- JSON Sort Keys — order the resulting object's keys.
- JSON Formatter — validate and re-indent the output.
Built by ByteVancer
ByteTools is a free product of ByteVancer, a software and web development studio building web apps, SaaS, and custom software. When your data plumbing outgrows a converter, explore how ByteVancer can build the real pipeline.
Recommended reading
How to Convert a URL Query String to JSON Online
Turn a URL query string or full link into pretty-printed JSON in your browser. Repeated keys become arrays and values are decoded.
When to Convert Query Strings to JSON: Real Examples
Debugging APIs, mocking payloads, reading webhook redirects, and documenting endpoints — real workflows for query string to JSON.
URL Decoder Use Cases: Logs, Analytics, APIs and QA
Real URL decoder use cases with examples: reading server logs, analytics UTM params, API redirect URIs, email tracking links and QA debugging of encoded strings.
URL Decoding Tips and the Mistakes That Break It
Pro URL decoding tips and common mistakes: plus-vs-space, double encoding, malformed % errors, UTF-8 characters and when to decode a path versus a query string.