1. Home
  2. Developer tools
  3. JSON to Query String

JSON to Query String

APIs disagree on how arrays and nested objects go into a URL. Paste JSON, pick bracket, repeated, indexed or comma style, and get a correctly percent-encoded query string you can append to a link.

Free, no sign-up. Runs in your browser: nothing is uploaded.

How to use JSON to Query String

  1. Paste the JSON object.
  2. Choose the array style and the other options.
  3. Copy the query string or the full URL.

Features

  • Four array styles: brackets, repeated keys, indices, comma
  • Nested objects with bracket keys
  • Space as + or %20
  • Skip null values and sort keys
  • Optional base URL, with ? or & chosen for you
  • Encodes the characters that encodeURIComponent leaves out

Supported formats

You can open

  • JSON

You get

  • Query string
  • URL

Private by design

Your files are opened and processed by your browser on this device. They are never uploaded to openWorkstand or anyone else, so the JSON to Query String is safe for contracts, IDs, photos and work documents. After you have used it once while online, it also works without an internet connection. How local processing works

Good to know

  • There is no single standard for arrays and nested objects in a query string; match the style your server reads.
  • Only JSON values can be given: functions and other non-JSON values cannot appear in the input.

Guide

Building query strings from JSON objects without surprises

Passing structured data in a URL is a compromise: a query string is a flat list of text pairs, while the data you have is usually an object with lists and nested parts. Different libraries squeeze one into the other in different ways, and mismatches between a client and a server cause filters that silently do nothing. This page produces the form you choose and shows it.

Array styles

Four conventions are in use. Brackets, tags[]=a&tags[]=b, are what PHP, Rails and many Node libraries produce. Repeated keys, tags=a&tags=b, are what plain HTML forms send for multiple selections. Indices, tags[0]=a&tags[1]=b, keep the order explicit and are the default of some libraries for arrays of objects. A comma list, tags=a,b, is compact and common in public REST APIs, but it breaks if a value contains a comma. The selector at the top lets you switch while watching the output.

Nested objects

An object inside an object is written with bracket keys: {“filter”: {“size”: {“min”: 38}}} becomes filter[size][min]=38. Servers that understand the convention rebuild the object; servers that do not see a parameter with a strange name. If an API instead expects dotted names or a single JSON string in one parameter, this page is not the right tool, though you can paste the JSON into the URL encoder for the second case.

Encoding

Every key and value is converted to UTF-8 and percent-encoded. JavaScript’s encodeURIComponent leaves the characters ! ’ ( ) * alone; the page escapes them as well, because some parsers and proxies treat them as special. A space is written %20 by default, which is valid anywhere in a URL. The “Space as +” option writes a plus sign instead, the form used by HTML form submissions, which is only right in a query string.

Other options

“Skip null values” drops pairs whose value is null, since there is no standard way to represent null in a query string. “Sort keys” orders the pairs alphabetically, which helps when comparing two URLs or building a stable cache key. A base URL, if you enter one, is joined with a question mark, or with an ampersand if it already contains one, and the page shows the full address. Booleans and numbers are written as text, so true appears as true.

A worked example

The Sample button loads an object with q, page, tags, filter, instock and coupon. With bracket arrays the output is q=red%20shoes%20%26%20boots&page=2&tags%5B%5D=sale&tags%5B%5D=new&filter%5Bcolor%5D=red&filter%5Bsize%5D%5Bmin%5D=38&filter%5Bsize%5D%5Bmax%5D=44&instock=true. The coupon pair is missing because its value is null and skipping is on, and the ampersand inside “red shoes & boots” is escaped so it does not split the pair. A small object with a list and a nested key gives tags=a&tags=b&n%5Bx%5D=1 with repeated keys and tags=a,b&n%5Bx%5D=1 with a comma list.

Limits

The page produces strings; it cannot know how your server will read them, so test against the real endpoint. Arrays of objects work with brackets and indices but are not understood by every parser. Values that are not JSON, such as dates, are written as the text you provide. Very large objects produce very long addresses, and browsers, proxies and servers limit URL length, commonly to a few thousand characters, so send big payloads in a request body instead.

Checked against the current version of the JSON to Query String on .

Troubleshooting

The file does not open

Check that it is one of the supported formats above and opens in another app. Damaged files and password-protected PDFs cannot be read until they are repaired or unlocked.

It is slow or stops on a very large file

Everything runs on your device, so speed depends on its memory. Close other tabs, use a computer rather than a phone, or split the file into smaller parts first.

The download did not start

Look for your browser’s download bar or icon. Some browsers ask once before a site may download files; allow it and click the button again.

Frequently asked questions

My server only sees the last value of a repeated parameter. What should I change?

Many servers keep a single value per name unless told otherwise. Use the bracket style, tags[]=a&tags[]=b, if the framework supports it, or send a comma list and split it yourself. The API documentation should state which form it reads.

Why are the brackets in the output written as %5B and %5D?

Square brackets are not allowed unescaped in the query part of a URL by the current standard, so they are percent-encoded. Servers decode them before looking at the names, so tags%5B%5D=a is read as tags[]=a.

Which array format should I use?

Use the one your server reads. PHP and Rails expect brackets, Express with qs accepts brackets and indices, and many REST APIs expect repeated keys. When unsure, check the API’s documentation.

Is a space %20 or +?

Both are read as a space in a query string, but only %20 is valid in a URL path. Form posts use +; this page lets you choose.

Keep working with the result

openWorkstand also includes a free workspace with documents, spreadsheets, tasks, projects and a calendar that save to a folder on your computer.