Skip to content
GivenTool

Minify JSON

Strip every unnecessary space and line break from JSON and see how many bytes you saved.

0 / 2,000,000 characters · Updates as you type.

Settings

Gives a canonical order, handy for comparing or caching.

Runs in your browser. Nothing you type is sent anywhere.

Pretty-printed JSON is written for people. Machines do not need the indentation and line breaks, and in some places they cost real money or break things: a config value stored in an environment variable must fit on one line, a JSON payload inside a URL or a data attribute should be as short as possible, and an API response sent millions of times a day pays for every byte. Minifying removes all whitespace that is not inside a string and leaves the data exactly as it was.

The minifier parses your JSON first, so it doubles as a validator: if there is a trailing comma, a missing quote or a comment, you get the line and column of the problem instead of silently broken output. The result shows the original size, the minified size and the percentage saved, in UTF-8 bytes, which is what goes over the network. Optionally, keys can be sorted alphabetically at every level, so two documents with the same content minify to the same text, which helps when comparing, caching or hashing them.

Minification is not compression. HTTP servers usually gzip or Brotli-compress responses, which removes most of the benefit of minifying for large files; minifying still helps with small payloads, storage in databases and anywhere compression is not applied. Everything runs locally, so API keys and customer data you paste are never transmitted.

How to use it

  1. Paste your JSON into the input box.
  2. The minified result appears as you type, with the byte count before and after.
  3. Turn on key sorting if you need a canonical order.
  4. Copy the single-line result or download it as minified.json.

Frequently asked questions

Does minifying change my data?

No. Only whitespace between tokens is removed. Strings, including spaces inside them, numbers and the order of arrays are unchanged.

Why do I get an error?

Minifying needs valid JSON. Common causes are trailing commas, single quotes, unquoted keys and comments, none of which JSON allows. The error shows where the parser stopped.

Are big numbers safe?

Numbers are read as JavaScript doubles, so integers above 9,007,199,254,740,991 lose precision, as in any browser. Store such IDs as strings.

How do I turn minified JSON back into readable JSON?

Use the JSON formatter, which pretty-prints with 2 or 4 spaces or tabs.

Is there a size limit?

Up to 2 million characters, about 2 MB. Larger files are better handled with a command-line tool such as jq -c.