Minifying JSON removes all the whitespace that exists only for human readers: spaces, tabs and line breaks between tokens. The data itself is unchanged, and any JSON parser reads the minified version exactly as it reads the formatted one. This guide covers how minification works, how much it really saves, and when it's worth doing.
Pretty printed:
json{ "a": 1, "b": [ 1, 2, 3 ], "c": "hello" }
Minified:
json{"a":1,"b":[1,2,3],"c":"hello"}
Whitespace inside strings is part of the data, so a minifier leaves "hello world" alone. Only whitespace between tokens is removed.
In the browser: paste your JSON into the JSON Formatter and click Compact. The editor validates the input first, so you'll know immediately if something is wrong.
In JavaScript: JSON.stringify without an indent argument produces minified output:
javascriptconst minified = JSON.stringify(JSON.parse(text));
In Python: pass compact separators, otherwise Python adds a space after : and ,:
pythonimport json minified = json.dumps(data, separators=(",", ":"))
On the command line: jq -c . input.json prints compact output.
For typical pretty-printed API responses, minification removes roughly 10–30% of the bytes, depending on nesting depth and indent size. Deeply nested data with four-space indentation shrinks the most.
That sounds significant, but on the web most JSON is also compressed with gzip or Brotli before it's sent. Compression is very good at squeezing repeated whitespace, so after compression the difference between minified and pretty-printed JSON is often only a few percent. Minifying is still worthwhile at scale, but compression matters far more. Check that your server sends Content-Encoding: gzip or br before optimizing anything else.
Minified JSON is just as readable to anyone who runs it through a formatter. Don't rely on it to hide data. If a payload contains secrets or personal information, remove or mask them first; see Redact / sanitize JSON.
If minification fails, the input isn't valid JSON. The usual causes are trailing commas, comments and single quotes; see Validate JSON. If the output looks "too small", check whether a tool also dropped null values or empty objects. A true minifier never removes data.