How to use the JSON Minifier
- Paste JSON or open a
.jsonfile. - The JSON is validated and minified instantly; errors show the line and column.
- Optionally sort keys alphabetically or write each array item on its own line (NDJSON).
- Copy or download the minified JSON.
What is JSON minification?
Minifying JSON removes every space, tab and line break that is not inside a string. The data is unchanged — JSON.parse returns exactly the same object — but the text is smaller. Pretty-printed JSON with two-space indentation is often 20–40 % larger than its minified form.
{
"id": 42,
"tags": ["a", "b"]
}
becomes {"id":42,"tags":["a","b"]}.
When to minify JSON
- API responses and config shipped to browsers — fewer bytes over the network.
- Storing JSON in databases, Redis, cookies, environment variables or query strings where size limits apply.
- Embedding JSON-LD or app state in HTML.
For files you edit by hand, keep the formatted version in your repository and minify during the build. Use the JSON formatter to turn minified JSON back into readable form.
Minified vs gzipped size
Gzip and Brotli are very good at compressing repeated whitespace, so after HTTP compression the difference between formatted and minified JSON shrinks to a few percent. The stats show both numbers so you can judge whether minifying is worth it for your case. For big payloads, removing unused fields and shortening repeated keys saves far more.
Sort keys and JSON Lines
| Option | Use it for |
|---|---|
| Sort keys | Stable output for diffs, caching keys and signatures — two objects with the same data produce identical text |
| JSON Lines | Log files, BigQuery and Elasticsearch bulk imports, streaming — one JSON value per line |
Validation
Because the JSON is parsed before it is minified, the tool doubles as a validator: trailing commas, single quotes, comments and unquoted keys are reported with their position. Large numbers keep JavaScript’s precision limits — integers above 253 may lose digits.
Tools that pair well with the JSON Minifier
- JavaScript Minifier — Paste JavaScript and get production-ready minified code from Terser — the same engine used by Vite, webpack and Rollup — with real before/after and gzipped sizes.
- JSON to CSV — Turn a JSON array into a spreadsheet-ready CSV.
- XML Minifier — Compact XML documents, feeds, sitemaps and SOAP payloads by removing indentation and comments — with a well-formedness check so nothing breaks.
- Website Compression Test — Enter a URL to see which compression your server sends for each Accept-Encoding, how many bytes it saves, whether its CSS and JavaScript are compressed, and what Brotli could save.