json:yaml

JSON minifier

Strip every byte of insignificant whitespace from a JSON document. The data is untouched — only newlines, indentation, and padding spaces are removed.

JSON
JSON

      
Paste JSON to convert.

Conversion happens in this browser tab. Nothing is uploaded, logged, or stored.

What minifying removes

Every byte of insignificant whitespace: the newlines between keys, the indentation, and the space after each colon and comma. The data is untouched. Parse the minified output and you get exactly the same value back.

Set indent to 0 in the controls above to minify; any other value re-formats instead. The two operations are the same round trip with a different output setting, which is why validity is checked either way.

How much you actually save

Minification typically removes 15–30% of a formatted JSON document, and more from deeply nested ones where indentation dominates. But the honest number is smaller than that, because almost every HTTP response is already gzip- or brotli-compressed, and compression is extremely good at repeated whitespace.

VersionRawAfter gzip
Formatted, 2-space100%~22%
Minified~72%~20%

Over the wire, minifying on top of compression saves a couple of percent. That is not nothing at scale, but it is not the reason to do it either. The real reasons are: embedding JSON in an environment variable or a single-line log entry, keeping a config blob inside a shell command, or meeting a hard size limit on a field.

To go back the other way, the JSON formatter will expand it again — minifying loses no data, so the round trip is safe.

What you should not do is minify files that humans edit. A minified config.json in a repository produces diffs that are one enormous changed line, which makes review impossible.

Minifying from the command line

jq -c '.' input.json > output.min.json

python -c 'import json,sys; json.dump(json.load(sys.stdin), sys.stdout, separators=(",",":"))' \
  < input.json > output.min.json

The separators argument matters in Python. Without it, json.dumps still writes a space after every comma and colon, so you get a single line that is not actually minimal.

Nothing is uploaded

Minifying is usually the last step before a document gets embedded somewhere awkward: an environment variable, a Kubernetes secret, a CI variable, a single-line argument. Those destinations are precisely where credentials live, so the blob being minified is often the most sensitive thing on the page.

It never leaves your browser. The document is parsed and re-serialised locally, and there is no request carrying it anywhere.

Questions people ask

How much smaller does minifying make a file?
Typically 15 to 30 percent of raw bytes. After gzip or brotli compression the saving drops to a couple of percent, because compression already handles repeated whitespace well.
Is it worth minifying API responses?
Marginally, if they are already compressed. The stronger reasons to minify are embedding JSON in an environment variable, a single-line log entry, or a field with a hard size limit.
Does minifying change my data?
No. Whitespace between tokens carries no meaning in JSON, so removing it cannot alter a value. The one thing to watch is that whitespace inside a string is not touched either — a minifier that shortened "New York" would be broken.
Should I commit minified JSON to a repository?
No. A minified file produces diffs that are one enormous changed line, which makes review impossible. Keep the source formatted and minify in the build step.
How do I minify from the command line?
jq -c '.' input.json is the shortest way. In Python, json.dump with separators=(',', ':') — without that argument you still get spaces after commas.