Minify JSON
Strip every space, newline and indent from a JSON document, and see how many bytes that saved. It validates as it minifies, so invalid JSON is reported rather than silently mangled. Nothing you paste leaves your browser.
How do I minify a JSON file?
What minifying JSON does, and what it is worth
Minifying JSON removes every character that a parser does not need: the newlines, the indentation, and the space after each colon and comma. The data is identical afterwards — same keys, same values, same order, same structure — because whitespace between tokens carries no meaning in JSON. What changes is the size, and on a heavily indented document that is a larger difference than people expect. A two-space-indented config file commonly loses 20 to 30% of its bytes, and a deeply nested API response can lose more.
When it is worth doing
The clear cases are anything crossing a network repeatedly or being stored at volume: API responses, config bundled into a web page, documents in a cache, payloads in a message queue. Over a lot of requests, whitespace is real bandwidth. It also matters against a hard limit — a field with a maximum length, a URL parameter, a message size cap — where minifying is sometimes the difference between fitting and not.
The case where it is not worth doing is a file a person reads or edits. A minified config file is genuinely hostile to work with, and version control makes it worse: a one-line document produces a diff of the entire line for any change, so review becomes impossible. Keep the readable version in the repository and minify as a build step, not as an edit.
Gzip does most of this already
It is worth being honest about the size gain. Any server worth using compresses responses with gzip or brotli, and repeated whitespace is exactly what those algorithms are best at. After compression, the difference between minified and formatted JSON is often small — sometimes only a few percent. Minifying still helps, and it helps most where compression is not in play: data stored in a database column, embedded in another document, or held in a size-limited field.
Formatting is the opposite operation
To go the other way and make a document readable, the JSON formatter and validator indents it and shows you exactly where it breaks if it will not parse. The two live on separate pages deliberately: they answer opposite needs, and a page trying to do both serves neither well. Both run in your browser, which matters given how often the JSON people need to inspect is a live API response carrying tokens or customer records.
Next steps
Related tools
- format it readably instead — the opposite operation, and the one to use while you are debugging.
- encode the payload — once it is small enough to travel in a header.
What to do with the result
- fingerprint the output — to confirm two payloads are identical.
Browse all developer utilities, or see every QuickMerge tool.
Frequently asked questions
Paste the document above. It is parsed, validated and re-serialised with no whitespace as you type, and the byte counts show what that saved. Copy the result or download it as a .json file.
No. Whitespace between tokens carries no meaning in JSON, so the keys, values, order and structure are all identical afterwards. Only the byte count changes.
Typically 20 to 30% on a two-space-indented document, and more on deeply nested data. The saving comes entirely from indentation and newlines, so a document that was already compact barely changes.
Less than you might think. Gzip and brotli compress repeated whitespace very effectively, so the post-compression difference is often only a few percent. Minifying helps most where compression is not involved: data in a database column, embedded in another document, or in a size-limited field.
No. A minified document is one long line, so any change produces a diff of the entire line and review becomes impractical. Keep the readable version in the repository and minify as a build step.
Use the JSON formatter, which indents it readably and validates it at the same time. Nothing is lost by minifying, so the round trip is exact.
No. Parsing and re-serialising both happen in this browser tab. That matters because the JSON people most often need to process is a live API response, and those routinely carry bearer tokens and customer data.