What does a JSON minifier do?
A JSON minifier removes every space, tab and line break that JSON allows between tokens, producing the same data on a single line in as few bytes as possible. It's used for payloads sent over the network, values stored in databases or environment variables, and JSON embedded in other files where size or a single line matters.
RFC 8259 calls that formatting "insignificant whitespace": parsers ignore it, so dropping it doesn't change what a program reads. Whitespace inside string values is part of the data and is always kept.
How to minify JSON
- Paste formatted or partly formatted JSON into the input box.
- Click Minify.
- Copy the single-line result from the output panel.
The input has to be valid JSON first. If it isn't, you'll see the parser's error message (with a line and column in Chrome and Edge) and no output. Use the JSON validator if you only want the yes/no check.
Worked example
This 331-byte order record, indented with two spaces:
{
"order": {
"id": 1042,
"status": "shipped",
"items": [
{
"sku": "A-100",
"qty": 2,
"price": 9.99
},
{
"sku": "B-205",
"qty": 1,
"price": 24.5
}
],
"customer": {
"name": "Ada Lovelace",
"email": "ada@example.com"
}
}
}
minifies to 185 bytes, about 44% smaller:
{"order":{"id":1042,"status":"shipped","items":[{"sku":"A-100","qty":2,"price":9.99},{"sku":"B-205","qty":1,"price":24.5}],"customer":{"name":"Ada Lovelace","email":"ada@example.com"}}}
The saving depends on how deeply nested the data is and how it was indented. The same object with 4-space indentation is 443 bytes, so minifying it saves even more.
Minifying and gzip
Most web servers compress responses with gzip or Brotli, which already squeezes out repetitive whitespace. For the example above, gzip shrinks the indented version to 194 bytes and the minified one to 158. Minifying still helps, but by far less than the uncompressed numbers suggest. It matters more where nothing compresses the data: JSON stored in a database column, in local storage, in a URL, or inside an HTML page.
Side effects of re-serializing
The tool works by parsing your JSON and writing it back out with JSON.stringify. That's reliable, but it means the output is a fresh serialization, not your text with spaces deleted:
| Input | Minified output | Why |
|---|---|---|
{"id":1,"id":2} |
{"id":2} |
Duplicate keys keep the last value |
{"a":"x","2":"y"} |
{"2":"y","a":"x"} |
Integer-like keys are ordered first |
{"p":1.50,"q":1e3} |
{"p":1.5,"q":1000} |
Numbers are normalized |
{"n":12345678901234567890} |
{"n":12345678901234567000} |
Above 2^53 - 1, integers lose precision |
{"c":"é"} |
{"c":"é"} |
Unicode escapes are decoded |
If your data contains IDs longer than 15 or 16 digits, store them as strings, or the minified file will hold different numbers than the original.
Minifying is also one-way in practice: the original indentation and key order can't be recovered. Keep the readable version in source control, and use the JSON formatter when you need to read a minified file again.
Other minifiers
- HTML minifier for markup.
- CSS minifier for stylesheets.
- Online JSON editor to edit JSON with highlighting before you minify it.
Last updated