JSON Minifier

Remove indentation, line breaks and spaces from JSON to make it as small as possible. The size before and after, and the bytes saved, are shown above the output.

Loading tool…

About the JSON Minify

JSON allows whitespace only between tokens, so minifying is lossless: the tool parses the document and re-serializes it with no spaces or line breaks. Whitespace inside strings is kept, because it is part of the data. The status line shows the UTF-8 size before and after and how many bytes were removed — typically 15–40% for pretty-printed files, depending on nesting depth and indentation width.

Minified JSON is useful for fixtures embedded in code, environment variables and CLI arguments that must fit on one line, localStorage values and message queues with size limits. For HTTP responses the gain is smaller than it looks: gzip or Brotli already compress repeated indentation very well, so enable compression on the server first and minify as a second step.

Because the input is parsed first, invalid JSON is reported with its line and column instead of being mangled. Sort keys A→Z produces a canonical key order, handy when you hash or compare payloads. The same limits as JavaScript apply: duplicate keys collapse to the last value and integers above 253 − 1 are rounded; both are flagged when they occur.

How to use it

  1. Paste formatted JSON or open a file.
  2. Optionally tick Sort keys A→Z.
  3. Check the size and savings in the status line.
  4. Copy the one-line result or download data.min.json.

Frequently asked questions

Does minifying JSON change the data?
No. Only whitespace between tokens is removed. Values, including spaces inside strings, are unchanged. The exception is precision loss for integers above 2^53, which the tool warns about.
Should I minify JSON API responses?
Most frameworks already send compact JSON. If yours pretty-prints, minifying helps, but enabling gzip or Brotli compression gives a larger reduction.
How do I minify JSON on the command line?
With jq: jq -c . input.json. With Python: python -m json.tool --compact input.json (Python 3.9+).

Related tools