Shard Tools

JSON to Query String

Turn a JSON object into a properly encoded URL query string in your browser, with arrays repeated correctly.

Maintained by Roshan.

Use JSON to Query String

Converts JSON into Query string in this tab. Configuration files routinely hold hostnames, keys and credentials, so nothing here is sent anywhere.

Values are never retyped as numbers or booleansGuessing types is how a converter turns a postcode of 0123 into 123, or a literal string of false into a boolean. Values are carried across as they were written, and casting is left to you where it matters.

Explore developer and data tools

Find related browser-local tools for nearby tasks without starting another search.

Browse all developer and data tools

About JSON to Query String

Building a query string by hand is one of those tasks that seems too simple to get wrong and is wrong surprisingly often. Every value needs percent-encoding, and the characters that need it are not the ones people expect: a space, an ampersand and an equals sign are obvious, but so are the plus sign, the hash and a good deal of punctuation, and missing one produces a URL that works for most inputs and breaks for a particular customer name. This converter uses the browser's own encoder, which is the same code that would encode the URL if the browser built it. Arrays are written as the key repeated, which is the convention almost every server-side framework understands, rather than any of the bracketed variations that only some do.

Work through the input

  1. Each top-level property becomes one parameter, encoded with the browser's own URL encoder so the escaping matches exactly what a browser would produce.
  2. An array value produces the key repeated once per item, in order, which is the form the widest range of servers parse correctly.
  3. Non-string values are converted to text first, since a query string can only carry text.
  4. Nested objects are serialised as JSON within the value, because there is no universally understood way to express nesting in a query string.
  5. The output omits the leading question mark, so it can be appended to an address that may already have a path or an existing query.

When json to query string is useful

Building a link with several filters

Express the filters as an array in JSON and the output repeats the key correctly, which is what most backends expect.

Reproducing an API call in the browser

Construct the parameters as JSON, convert, and append to the endpoint. The encoding will be correct even for values containing punctuation.

Check the output

Questions about JSON to Query String

How are arrays encoded?

As the key repeated once per value. That form is understood by the widest range of servers, though a few expect bracketed indices instead.

Is there a leading question mark?

No, deliberately, so the result can be appended to a URL that may already have a query.

What happens to nested objects?

They become JSON text inside the value. Query strings have no agreed syntax for nesting.

Is the encoding correct for unusual characters?

Yes. The browser's own encoder is used, so the result matches what a browser would produce.

Should I put a password in a query string?

No. URLs are recorded in server logs, proxies and browser history. Use a request body instead.

Related tools

Query String to JSON

Turn a URL query string into readable JSON in your browser. Repeated keys become arrays rather than being lost.

URL Encoder and Decoder

Percent-encode and decode URLs in your browser, choosing between encoding a value inside a URL and encoding a whole address. Shows which characters differ.

JSON to XML

Turn JSON into well-formed XML in your browser, with escaping and element naming handled correctly.