In this article
What minifying does
Formatted JSON uses spaces and line breaks to show structure. Computers do not need them. Minifying removes all whitespace outside string values, so { "name": "Ali Khan", "age": 30 } becomes {"name":"Ali Khan","age":30}. Spaces inside values – like the one in “Ali Khan” – are kept, because they are part of the data.
How much does it save?
| JSON | Formatted | Minified | Saving |
|---|---|---|---|
| Deeply nested config, 4-space indent | 48 KB | 29 KB | about 40% |
| API response, 2-space indent | 120 KB | 95 KB | about 20% |
| Flat list with long text values | 300 KB | 285 KB | about 5% |
The deeper the nesting and the shorter the values, the more whitespace there is to remove. These are typical figures; the JSON Minifier shows the exact bytes saved for your data.
The gzip twist
Most web servers compress responses with gzip or Brotli before sending them. Repeated whitespace compresses extremely well, so after compression the difference between formatted and minified JSON shrinks to a few percent. If your server already compresses JSON, minifying is a small extra gain rather than a big one. If it does not compress (some simple hosts and file downloads), minifying matters more – and turning on compression matters most of all.
When to minify
- Static JSON files served to websites and apps, such as translations or product data.
- Data stored in databases, local storage or cookies, where every byte counts.
- Embedding JSON in HTML or JavaScript (for example JSON-LD structured data generated by a script).
- Sending data over very slow or metered connections.
When not to minify
- Configuration files people edit by hand – readability prevents mistakes.
- Files kept in Git – formatted JSON gives clean, line-by-line diffs.
- Logs and debugging output – you will need to read them.
How to minify safely
- Paste your JSON into the JSON Minifier.
- It validates first – broken JSON is never “minified” into something worse; you get an error with the position instead.
- See the bytes saved, then copy or download the .json file.
Need it readable again? Paste minified JSON into the JSON Formatter – minifying is fully reversible apart from key order and spacing.
Minifying JSON-LD and embedded data
Structured data for search engines (JSON-LD) sits inside a script tag on every page. Minifying it saves a little on each page view; more importantly, it avoids accidental line breaks and indentation errors when templates paste it in. Validate it afterwards with Google’s Rich Results Test, and generate it in the first place with the Schema Generator.
Bigger wins than whitespace
If JSON size is a real problem, look at the data: remove fields the client never uses, shorten very long arrays with pagination, and avoid sending the same nested object many times. Those changes often save far more than minifying.
Related
For front-end files, the CSS Minifier and JavaScript Minifier do the same job for stylesheets and scripts.