RFC 8259 defines four whitespace characters (space, tab, line feed and carriage return) that
may appear before or after any of the six structural characters { } [ ] : ,.
The specification calls this whitespace insignificant, and every conforming parser
discards it. Removing all of it is therefore always safe.
Whitespace inside strings is data and is kept. In
{"note": "two spaces\n"}, the double space and the escaped newline survive
minification exactly. Only the space after the colon goes away.
Because this tool re-serializes the parsed value instead of deleting characters with a regular expression, some things are normalized along the way. None of these change the meaning for a JavaScript consumer, but you should know about them:
- Number formatting is canonicalized:
1.0becomes1,1e2becomes100. - Unnecessary escapes are written as plain characters:
"é"becomes"é", which is one character but two UTF-8 bytes. - Integers above 253 lose precision, as they do in any JavaScript parser.
- Integer-like keys move to the front:
{"b":1,"2":0}becomes{"2":0,"b":1}. Duplicate keys collapse to the last value.
If a payload carries 64-bit IDs or high-precision decimals as bare numbers, minify it with
jq -c (jq 1.7 or later) instead. It keeps number literals exactly as written.