How to use the query string to json converter
- Paste your query string or full URL into the text area.
- Adjust the indent size if you prefer compact or expanded output.
- The JSON result updates live as you type.
- Copy the output for use in code, API testing or configuration files.
How query string parsing works
A query string follows the question mark in a URL and contains key-value pairs separated by ampersands. Each pair uses an equals sign to join the key and value. Converting a query string to JSON means splitting on those delimiters, decoding any percent-encoded characters and building a structured object.
For example, the input name=Alice&age=30 splits into two pairs. After decoding, the resulting JSON is {"name": "Alice", "age": "30"}. Note that all values remain strings because query strings carry no type information. If you need numbers or booleans, parse them after conversion using your language of choice.
The algorithm first strips any URL scheme, host, path or fragment so you can paste a complete address without manually isolating the parameters. It then splits the remaining string on every ampersand, ignoring empty segments caused by trailing or doubled ampersands. Each segment is split at the first equals sign only, which allows values to contain literal equals signs once decoded.
Handling repeated keys
URLs often repeat the same parameter name, such as tag=js&tag=web&tag=api. When converting a query string to JSON, these repeated keys are grouped into an array. The output becomes {"tag": ["js", "web", "api"]}.
If a key appears only once, its value stays a plain string rather than a single-element array. This matches the behaviour of Python's urllib.parse.parse_qs when configured to flatten single values, and keeps the JSON output clean for typical API payloads.
This design choice avoids unnecessary nesting. A search endpoint expecting ?q=test usually wants {"q": "test"}, not {"q": ["test"]}. However, if your downstream system always expects arrays, you can wrap single values programmatically after the conversion step.
Percent-encoding and plus signs
Characters outside the unreserved set must be percent-encoded in URLs. A space can appear as %20 or as a plus sign (+). Both forms are decoded back to a literal space during conversion. Other common encodings include %26 for an ampersand and %3D for an equals sign.
The converter applies standard URI decoding to every key and value. Malformed sequences like a lone percent sign at the end of the string will produce an error rather than silently corrupting the data. This strict approach prevents subtle bugs where partial decoding leaves garbage characters inside your JSON payload.
The plus-as-space rule comes from the application/x-www-form-urlencoded media type defined in the HTML specification. While RFC 3986 treats plus as a literal character in generic URIs, web forms and most server frameworks decode it as a space. This tool follows the web form convention because that is what developers expect when they parse query parameters from HTTP requests.
Common reference patterns
| Query string | JSON output |
|---|---|
a=1&b=2 | {"a":"1","b":"2"} |
x=1&x=2 | {"x":["1","2"]} |
flag | {"flag":""} |
k= | {"k":""} |
q=a+b | {"q":"a b"} |
s=%2Fpath | {"s":"/path"} |
The table above covers the most frequent edge cases. Bare keys without an equals sign map to empty strings. Empty values after an equals sign also map to empty strings. Plus signs become spaces, and percent-encoded slashes decode normally.
Worked examples
| Example | Input | Result |
|---|---|---|
| Simple parameters | Query string: name=Alice&age=30; Indent spaces: 2 | { / "name": "Alice", / "age": "30" / } |
| Repeated keys | Query string: color=red&color=blue&color=green; Indent spaces: 2 | { / "color": [ / "red", / "blue", / "green" / ] / } |
| Full URL with fragment | Query string: https://example.com/search?q=hello+world&lang=en&page=1#top; Indent spaces: 2 | { / "q": "hello world", / "lang": "en", / "page": "1" / } |
| Encoded special characters | Query string: email=user%40example.com&msg=100%25+done; Indent spaces: 2 | { / "email": "user@example.com", / "msg": "100% done" / } |
FAQ
Does this tool upload my data?
No. The query string to JSON conversion happens entirely in your browser using JavaScript. Nothing is sent over the network.
Can I paste a full URL instead of just the query string?
Yes. The tool automatically strips the scheme, host, path and fragment, keeping only the query parameters for conversion.
Why are all values strings in the output?
URL query parameters do not carry type information. Every value is treated as a string to avoid incorrect assumptions about numbers or booleans.
What happens if a key has no equals sign?
A bare key like flag is parsed with an empty string as its value, producing {"flag": ""} in the JSON output.
How are duplicate keys handled?
When the same key appears more than once, the values are collected into a JSON array under that key.
Is the plus sign decoded as a space?
Yes. In application/x-www-form-urlencoded data, which query strings follow, a plus sign represents a space character.