Command Palette

Search for a command to run...

QU

Query String Parser

Parse a URL query string into structured JSON, or build a query string from a JSON object. Handles repeated keys, bracket arrays, and encoding. 100% client-side.

What is a query string parser?

A query string parser converts the part of a URL after the question mark into structured data. The query string q=json+parser&page=2 becomes the object {"q":"json parser","page":"2"}, with each key and value URL-decoded so a plus sign turns back into a space and %2F turns back into a slash. This tool parses in that direction, and also runs the reverse: it builds a correctly encoded query string from a JSON object of key-value pairs.

Query strings look simple until repeated keys and array syntax appear. The same key can occur more than once, as in tags=react&tags=laravel, and many frameworks encode arrays and nested objects with brackets, such as tags[]=react or filter[color]=red. A parser has to decide whether those become an array, a nested object, or a last-value-wins scalar, and different back ends disagree. This tool exposes those choices so the JSON you get matches the system that produced the URL, and the query string you build matches the system that will read it.

Everything runs in your browser. Parsing, decoding, and encoding are done in JavaScript, so nothing is uploaded, logged, or stored. That is worth having for URLs that carry session tokens, tracking parameters, or signed values in the query, because those never leave your machine, and the tool keeps working offline once the page has loaded.

Query strings have less of a standard than their ubiquity suggests, and repeated keys are where implementations diverge. Given a=1&a=2, some frameworks return an array, some the first value, some the last. Bracket notation such as a[]=1&a[]=2 is a PHP convention that many libraries adopted and no specification defines, so a server that does not know it will read the literal key a[]. Both forms are shown here so you can see what a given string actually contains. Encoding is the other half: a space may be a plus sign or %20 depending on whether the string came from a form submission or from a URL path, and the two are decoded differently. An ampersand inside a value has to be encoded, or it silently becomes a parameter separator.

How to use the query string parser?

  1. Choose parse or build

    Parse turns a query string or full URL into JSON. Build turns a JSON object into a query string. Load the sample to see both directions with arrays and encoding.

  2. Paste your input

    In parse mode, paste a full URL or a bare query string; the fragment after # is ignored and everything before ? is stripped. In build mode, paste a JSON object of key-value pairs.

  3. Set the options

    Pick how repeated keys are handled, whether bracket keys become nested structures, and how arrays are encoded when building. URL decoding and plus-as-space are on by default.

  4. Copy the result

    Read the parameter table and copy the JSON, or copy the generated query string, ready to paste into a URL, a fetch call, or a test.

Key Features

  • Two-way conversion

    Parse a query string into JSON and build a query string back from JSON in one tool, so you can round-trip a URL while editing its parameters.

  • Repeated keys and arrays

    Repeated keys can collapse to an array, keep the first value, or keep the last. Bracket keys like tags[] and filter[color] parse into arrays and nested objects.

  • Correct encoding and decoding

    Values are URL-decoded on parse and percent-encoded on build, with a plus-as-space option, so reserved characters such as &, =, and spaces survive the round trip.

  • Full URL or bare string

    Paste a whole URL and the parser strips the scheme, host, path, and fragment for you, or paste just the query string. Either way you get the same parameter table.

Frequently Asked Questions

A query string is the part of a URL after the question mark that carries parameters as key-value pairs joined by ampersands, such as ?q=json&page=2. Web servers and client code read it to filter results, track campaigns, or pass state. Each key and value is URL-encoded, so spaces and reserved characters are escaped.

Comments

0 comments

0/2000 characters

No comments yet. Be the first to share your thoughts!

query string parserparse query stringquery string to jsonurl query parserbuild query stringquerystring parserurl parameters parserquery string builderjson to query string