How to minify JSON
Minifying JSON removes spaces and line breaks. It does not change the data—only the formatting.
Before and after
Pretty printed:
{
"a": 1,
"b": [1, 2, 3],
"c": "hello"
}
Minified:
{"a":1,"b":[1,2,3],"c":"hello"}
When minifying helps
- Lower bandwidth for API requests/responses
- Smaller storage when saving JSON blobs
- Copy/paste convenience for short payloads
When not to minify
- When humans need to read or review the JSON
- When debugging errors (pretty print first)
Related: Pretty print JSON · Compare JSON