What is JSON minification?
Minifying JSON means removing all whitespace that is not inside a string: indentation, line breaks and spaces after colons and commas. The result is one line that any JSON parser reads to exactly the same data as the original. JSON's grammar in RFC 8259 allows whitespace around every structural character but gives it no meaning, which is why the transformation is safe and reversible: you can pretty-print the output again with the JSON formatter at any time.
How to minify JSON
- Paste the JSON or open a file. It is validated as you type.
- Optionally tick Sort keys for a canonical, order-independent form.
- Click Minify. The single-line result appears on the right with the original size, the new size and the percentage saved.
- Copy or download the result.
Example
{
"id": 42,
"tags": [ "a", "b" ],
"note": "two spaces stay"
}
minifies to {"id":42,"tags":["a","b"],"note":"two spaces stay"}. The double space inside the string is preserved because it is part of the value.
When minifying is worth it
- Payloads in URLs, headers or cookies, where every byte counts and there is no compression.
- JSON embedded in HTML, for example JSON-LD structured data or initial application state.
- Storage: JSON columns in databases, cache entries and message queues.
- Fixtures and snapshots where you want one record per line.
For responses served over HTTP with gzip or Brotli, minifying gives a smaller gain because compression already removes most of the repeated whitespace. It is still cheap to do in a build step.
Why validate before minifying?
A minifier that only deletes whitespace with a regular expression will happily turn broken JSON into broken JSON on one line, which is even harder to debug. This tool parses the input first. If it is invalid you get the list of problems with line numbers from the original, readable layout, and the minified output is produced only from a correct document. Numbers are copied exactly as written, so values beyond JavaScript's precision such as 12345678901234567890 are not rounded.