JSON URL Encode

Make a JSON filter safe to drop into a query string, a redirect target or a deep link.

JSON
Encoded
Runs locally in your browser

About the JSON URL Encode

Braces, quotes, colons and spaces all have to be escaped before JSON can travel in a URL. This encoder minifies the document first, so no indentation is wasted on percent escapes, then percent encodes every reserved character. The result pastes straight after an equals sign without a proxy, a log parser or a browser address bar mangling it.

Five output shapes cover the usual needs. The encoded value alone is what you want when the parameter name is already written. The name and value pair, and the full example URL, save a step when you are assembling a request by hand. Form encoding replaces %20 with a plus sign, which is what an HTML form body uses. The last shape flattens the document into one parameter per leaf, so sizes[0]=38 style pairs reach a server framework that expects them.

Watch the character count in the status line. Browsers and CDNs start truncating somewhere above two thousand characters, and a long filter reaches that faster than expected once every quote costs three characters. The status line warns when the encoded value crosses that mark, which is the point to move the payload into a POST body instead.

Sorting keys before encoding produces the same URL for the same filter every time, which keeps caches and analytics tidy. Reverse it with JSON URL Decode, or use the general URL Encode tool for plain text.

How to use

  1. Paste the JSON filter or payload, or press Sample to load a product search.
  2. Pick an output shape, from the bare encoded value to one parameter per field.
  3. Name the parameter when you chose a pair or a full URL.
  4. Check the character count in the status line, then copy the encoded value.

Common questions

Why encode at all when the browser accepts braces?
Browsers are forgiving but proxies, redirects and logs are not. Percent encoding keeps the value intact everywhere along the path.
How long can the URL be?
Treat two thousand characters as the practical ceiling across browsers and CDNs. Past that, send the JSON in a request body instead.
What is the difference between form encoding and normal encoding?
Form encoding writes a space as a plus sign, the convention for an HTML form body. Normal percent encoding writes it as %20.
When should I flatten into separate parameters?
When the server framework expects bracket style parameters such as filter[brand]. Flattening produces one pair per leaf value instead of a single blob.