JSON Minifier — compact JSON and remove whitespace
Input
emptyMinified JSON
What gets removed
Only whitespace that sits between tokens: newlines, indentation, and the spaces after colons and commas. Whitespace inside a string is data and is never touched, so {"note": "hello world"} keeps both of its spaces. Nothing else changes — no keys are dropped, no numbers are rewritten, no values are reordered. The output parses to a value that is deeply equal to the input.
JSON has no other compressible syntax. There are no comments to strip and no optional punctuation to drop, which is why JSON minification is far simpler — and far more predictable — than minifying JavaScript or CSS.
How much you actually save
On a pretty-printed document the raw saving is large: deeply nested JSON is mostly indentation, and cutting a third or more of the bytes is unremarkable. The tool prints the exact figure for your input rather than a claim.
Be careful about what that number means over the wire, though. Indentation is long runs of identical characters, which is the single most compressible thing there is, so if your server already sends Content-Encoding: gzip or br — and it should — most of that saving has already been taken. Minifying is worth real bytes for uncompressed transports, for values stored in a database column or a cache, and for anything counted against a payload size limit. It is worth much less for an HTTP response that was going to be compressed anyway.
When not to minify
Anything a human reads or a version control system tracks. A minified file is one enormous line, so every change shows as a rewrite of the whole file and line-based review becomes impossible. Config files, fixtures and checked-in data belong pretty-printed; minify at the point of transmission or storage, not in the repository.
If you have inherited a minified file and need to read it, the JSON beautifier is the exact inverse of this page.
Invalid JSON cannot be minified
Whitespace can only be removed safely by a parser that knows which whitespace is inside a string, so the document has to parse first. A regex that strips spaces will corrupt string values sooner or later. If the input is rejected, the error above gives the line and column; the JSON validator will repair the usual causes and the JSON error reference explains the message.
Large files, and privacy
Minifying runs in a Web Worker so the page stays responsive, and results above 20 MB are offered as a download rather than rendered into an editor. The ceiling is 50 MB. Because all of this happens in your browser, nothing you paste is transmitted anywhere — there is no upload step to opt out of.