Query String Parser

Paste a query string, or a whole URL, and see the parameters as decoded key-value pairs. Repeated keys such as tags[]=react&tags[]=astro are kept in full: one table row per value, and an array in the JSON view, so no value overwrites another.

Input (URL or Query String)
Key Value
Results will appear here...

1 What the parser does

Repeated keys

A key that appears more than once, such as tags[]=a&tags[]=b, becomes an array in the JSON. Keys are kept as written, so user[name] is not expanded into a nested object.

Decoding

Values are decoded with URLSearchParams, so %20 and + both become a space.

2 Query String Parser example output

Parsed JSON

1
2
3
4
5
6
7
8
9
10
{
  "q": "developer tools",
  "category": "web",
  "tags[]": [
    "react",
    "astro"
  ],
  "sort": "newest",
  "page": "1"
}

3 Faster than reading the raw string

  • An API call returns the wrong result, and you need to see which parameters made it into the request.
  • A campaign URL has five UTM parameters, and you need to find the misspelled one.
  • A redirect carries another encoded URL inside it, and you need to see where it points.

How to use the Query String Parser tool

  1. Paste a query string such as q=hello&page=2, or a full URL, and the tool takes everything after the ?. Upload File and Dummy Data are in the toolbar.
  2. The Table tab lists every key and its decoded value. Repeated keys produce one row each, so tags=react&tags=astro shows two rows.
  3. Switch to the JSON tab to see the same data as an object. Keys that appear more than once become arrays, and single keys are plain strings.
  4. Click Copy (shown on the JSON tab) to copy the object, or Clear to reset.

How to parse a query string into an object in JavaScript, PHP and Python

JavaScript / Node.js

const qs = "?q=hello+world&page=2&tags=react&tags=astro";

const params = new URLSearchParams(qs);

console.log(params.get("q"));        // hello world
console.log(params.getAll("tags"));  // [ 'react', 'astro' ]
console.log(params.has("page"));     // true

// Plain object, last value wins for repeated keys
console.log(Object.fromEntries(params));

// Keep repeated keys as arrays (what the tool's JSON view does)
const result = {};
for (const key of new Set(params.keys())) {
  const all = params.getAll(key);
  result[key] = all.length === 1 ? all[0] : all;
}
console.log(JSON.stringify(result, null, 2));

// Modify and serialize back
params.set("page", "3");
params.delete("q");
console.log(params.toString()); // page=3&tags=react&tags=astro

URLSearchParams decodes + as a space and ignores a leading ?. Every value is a string, so convert numbers yourself.

PHP

<?php
$qs = "q=hello+world&page=2&tags[]=react&tags[]=astro&user[name]=John";

// parse_str expands PHP-style brackets into nested arrays
parse_str($qs, $params);
print_r($params);

// In a web request the same data is already in $_GET
// echo $_GET["user"]["name"];

// Build a query string back from the array
echo http_build_query($params), PHP_EOL;
// q=hello+world&page=2&tags%5B0%5D=react&tags%5B1%5D=astro&user%5Bname%5D=John

Without brackets, a repeated key keeps only the last value in PHP: a=1&a=2 gives ["a" => "2"].

Python

from urllib.parse import parse_qs, parse_qsl, urlencode

qs = "q=hello+world&page=2&tags=react&tags=astro"

# Dict of lists: safe for repeated keys
print(parse_qs(qs))
# {'q': ['hello world'], 'page': ['2'], 'tags': ['react', 'astro']}

# List of (key, value) pairs in original order
print(parse_qsl(qs))

# Empty values are dropped unless you ask for them
print(parse_qs("a=&b=1", keep_blank_values=True))

# Serialize a dict back, expanding lists with doseq=True
print(urlencode({"page": 3, "tags": ["react", "astro"]}, doseq=True))

Django's request.GET and Flask's request.args wrap the same logic and offer getlist() for repeated keys.

Common errors and how to fix them

Only the last value of a repeated key is kept
Object.fromEntries(), PHP without [] and many simple parsers overwrite earlier values. Use getAll() in JavaScript, tags[] in PHP, or parse_qs() in Python, which always returns lists.
Key user[name] is shown literally instead of as a nested object
Bracket syntax is a PHP and Rails convention that no URL spec defines. URLSearchParams and this tool keep the key as written. Use parse_str() in PHP, or the qs package in Node.js, to expand it.
A value with & inside it was split into two parameters
The & was not encoded when the URL was built. Encode values with encodeURIComponent() or http_build_query() so & becomes %26.
Every number comes back as a string
Query strings carry text only. page=2 is the string "2". Convert with Number(), (int) or int() and validate before use.
Blank parameters disappear
Python's parse_qs() drops a= by default. Pass keep_blank_values=True. URLSearchParams and parse_str() keep them as empty strings.

Good to know

RFC 3986 does not define the key=value&key=value format. The URL spec only says a query starts at ? and ends at #, and the structure inside comes from the HTML form spec. This is why + means a space in a query and nowhere else in a URL, and why frameworks disagree about repeated keys, empty values and bracket syntax.

Sort the keys before you build a URL that will be cached or signed. Servers and caches compare query strings as text, so ?a=1&b=2 and ?b=2&a=1 can end up as two cache entries for the same page.

Specifications and references

This tool follows the specifications below. Read them when you need the exact normative wording, for example to settle an edge case between two implementations.

Frequently Asked Questions

Can I paste a full URL or just the query string?

Either. If the input contains a question mark, the tool parses everything after it, so a full URL works as well as a bare q=hello&page=2.

How are repeated keys handled?

Each occurrence gets its own row in the table, so tags[]=react&tags[]=astro shows two rows for tags[]. In the JSON view, the key holds an array of both values. Nothing is dropped.

Are bracket notations like user[name] expanded?

No. Keys are shown exactly as written, matching the browser's URLSearchParams. PHP's parse_str() or the qs package in Node.js expand bracket keys into nested objects.

Are values decoded?

Yes. URLSearchParams decodes percent-encoded sequences, and a plus sign becomes a space, as in a form submission.

Can I get the result as JSON?

Yes. Open the JSON tab to see the parameters as an object, then click Copy. Keys that appear once hold a string, and repeated keys hold an array.

Related

The URL parser breaks down the whole address, including host, path and fragment. For single values, encode and decode them directly.

More URL Tools

Browse all url tools

Copied to clipboard!