Indented JSON compacted
Input
{
"id": 42,
"tags": [
"a",
"b"
]
}Output
{"id":42,"tags":["a","b"]}From 48 characters to 26, a 45.8% reduction, with identical parsed data for this example.
Minifying JSON parses the input and serialises it without indentation, newlines or spaces between tokens. It produces a compact representation of the parsed value, not a whitespace-only edit of the original text. Parsing can discard duplicate keys and round numbers, and serialisation can change key order, numeric spelling and string escapes.
Savings depend on the input layout and on how parsed values are re-serialised. When output is shorter, this tool reports the decrease in JavaScript string length, measured in UTF-16 code units, and the percentage saved. The comparison excludes leading and trailing whitespace in the input; it is not an exact UTF-8 byte measurement.
Each example below is executed against this tool by the test suite, so what you see is what the tool actually produces.
Input
{
"id": 42,
"tags": [
"a",
"b"
]
}Output
{"id":42,"tags":["a","b"]}From 48 characters to 26, a 45.8% reduction, with identical parsed data for this example.
The details that decide whether a conversion is correct, and where information can be lost without any error being raised.