Query String to JSON

Convert a URL query string to JSON, or JSON back to a query string.

Result

{
  "q": "café au lait",
  "tag": [
    "a",
    "b"
  ],
  "page": "2",
  "sort": [
    "name",
    "date"
  ]
}
12 lines · 114 bytes
  • Names that repeat, or end in [], become arrays. All values are text, as in a real query string.

What is a query string?

A query string is the part of a URL after the question mark. It holds name and value pairs joined by &, like q=hello&page=2. Special characters are written as percent-escapes, and in form data a plus sign stands for a space.

JSON is easier to read and work with in code. This tool converts the query string into a JSON object with all the escapes decoded. Names that repeat, or that end in [], become arrays. It also works in reverse: paste a JSON object and get a properly encoded query string, with your choice of how arrays are written.

How to use the Query String to JSON

  1. Paste a query string or a whole URL, or paste JSON.
  2. Choose the direction.
  3. For JSON to query, choose how arrays are written.
  4. Copy the result.

Real situations

When people use the Query String to JSON

  • 1

    Read a long search or tracking URL

    Turn all the parameters into tidy JSON to see what is being passed.

  • 2

    Prepare test data for an API

    Write the parameters as JSON, then convert to a query string for a request.

  • 3

    Debug a form submission

    Paste the encoded body of a form to see each field and its value.

  • 4

    Choose an array style

    See how one list is written as tag=a&tag=b, as tag[]=a&tag[]=b or as tag=a,b, and pick what your server expects.

FAQ

Query String to JSON: questions answered

What does the sample become?

q=caf%C3%A9+au+lait&tag=a&tag=b&page=2&sort[]=name&sort[]=date becomes JSON with q "café au lait", tag ["a", "b"], page "2" and sort ["name", "date"]. The URL part before the question mark is ignored.

Why are numbers shown as strings?

A query string has no types, so every value is text. page=2 becomes "2". Your code must convert it to a number if it needs one.

How are arrays written in a query string?

There are three common styles. Repeating the name gives tag=a&tag=b. Brackets give tag[]=a&tag[]=b, with the brackets encoded as %5B%5D. A comma list gives tag=a,b. Which one works depends on the server you send it to.

How does JSON become a query string?

Paste an object such as {"q":"café au lait","tag":["a","b"]}. With repeat style the result is q=caf%C3%A9%20au%20lait&tag=a&tag=b. The JSON must be an object, not a list.

What is the difference between + and %20?

Both can stand for a space. In form-encoded query strings, + means a space. The tool reads + as a space when converting to JSON and writes %20 when building a query string.

Does it handle nested objects?

The tool is built for flat names and lists of text values. Deeply nested JSON has no single standard form in a query string, so check the output against what your server expects.

Is this Query String to JSON free and private?

Yes. It is free with no sign-in, and every calculation runs inside your browser. Nothing you type is sent to a server or stored, and the page keeps working offline once it has loaded.

Private by design. No accounts, no cookies, no tracking. Everything you type stays on your device.

How we keep it that way