Query String Parser

Parse a URL query string into decoded key/value pairs and a JSON object.

  • Runs locally in your browser
  • No upload required

Try it

Or drop a .json file here.
Parameters
4
Distinct keys
3
Repeated keys
1
q
hello world
page
2
tag
js
tag
css
{
  "q": "hello world",
  "page": "2",
  "tag": [
    "js",
    "css"
  ]
}

Supported formats

Input
text
Output
number, text

Privacy

Runs entirely in your browser. Your input is never uploaded, stored, or sent to a third party.

Processing
In your browser
Privacy level
Browser only

2 parameter(s); 2 distinct key(s).

How it works

  • Reduced the input to its query string (dropping any scheme, host, path and fragment).
  • Split on `&` and then on the first `=` in each segment.
  • Decoded each key and value with `application/x-www-form-urlencoded` rules (`+` is a space, then percent-decode).
  • Grouped repeated keys as arrays in the JSON object.
  • A parameter with no `=` is treated as a key with an empty value.
  • The JSON object lists a repeated key as an array of its values; the pair list keeps the original order.
  • Decoded with the standard form-urlencoded rules; a malformed percent-escape is left as-is.

Methodology

  1. Reduce the input to the substring after the first `?` and before any `#`.
  2. Split into segments on `&`, then split each at the first `=`.
  3. Decode each component with form-urlencoded rules and group repeated keys.

Usage

  1. Paste a query string (or a full URL) into the input.
  2. Read the decoded key/value pairs and the JSON object.
  3. Copy the JSON for use in your code.

Examples

These are examples, not current values: they use fixed inputs, while the interactive tool computes live results in your browser.

Two simple parameters

jsonSelect to copy
{
  "query": "?q=hello+world&page=2"
}

Repeated key

jsonSelect to copy
{
  "query": "tag=js&tag=css&q=x"
}

A full URL

jsonSelect to copy
{
  "query": "https://devplace.example/search?q=caf%C3%A9#results"
}

Limitations

Form-urlencoded decoding

Query strings follow the `application/x-www-form-urlencoded` rules: pairs are separated by `&`, keys and values by `=`, a literal space is written as `+` or `%20`, and other reserved characters are percent-encoded.

This tool decodes those rules and groups repeated keys, which is the shape most server frameworks and URLSearchParams produce. If the same key appears several times it is shown as an array.

Frequently asked questions

How are repeated keys handled?
The pair list keeps every occurrence in order, and the JSON object groups a repeated key into an array of its values.
Does it make a request?
No. It parses the text you paste; it never contacts the URL.

Sources

  1. WHATWG URL Standard: application/x-www-form-urlencoded — WHATWG
  2. MDN Web Docs: URLSearchParams — MDN