Query String Parser

Parse query strings into keys and values.

FreeNo accountOn your device

Runs in your browser. How to verify

Loading tool…

About this tool

Paste a query string, with or without the leading ? (a whole URL also works, and a #fragment is ignored), and get a JSON object of its keys and values. Percent-codes and plus signs are decoded. If a key appears more than once, only the last value is kept.

How to use

1
Step 1
Paste the query string, for example ?q=hello+world&page=2.
2
Step 2
Press Run.
3
Step 3
Copy the JSON.

How it works

The string is parsed with URLSearchParams, so %20 and + both become spaces and %26 becomes &. Each pair becomes a property of the result object. Values are always strings.

Worked example

A search query with a repeated key

Input
?q=hello+world&page=2&tag=a&tag=b
Output
{ "q": "hello world", "page": "2", "tag": "b" }
Walkthrough
The plus sign became a space, and tag shows b because the second tag overwrote the first.

Limitations

  • Repeated keys keep only the last value; all values are not collected into an array.
  • Values are strings, so page is "2", not the number 2.
  • Nested keys such as a[b]=1 are not expanded.

Questions

How do I parse a query string?
Paste it and press Run. You get a JSON object of the parameters.
Does it need the question mark?
No. With or without ? works.
What happens to duplicate keys like tag=a&tag=b?
Only the last value (b) is kept.
Does it decode %20?
Yes, percent-encoded characters are decoded.

Features

  • Decodes %XX and +
  • JSON output
  • Runs in your browser

Related resources

Guides and videos from around the web—opens on YouTube or the publisher’s site.

  • Learn JSON - Full Crash Course

    freeCodeCamp.org

    JSON is the payload format behind many developer tools here.

    Watch on YouTube
  • TypeScript in 100 Seconds

    Fireship

    Typed JS snippets often get formatted or hashed nearby.

    Watch on YouTube