How much space whitespace takes

Pretty-printed JSON typically spends 20–40% of its characters on indentation and line breaks, depending on nesting depth. Minifying a 1 MB formatted file often produces 600–750 KB. Gzip or Brotli on top of that usually beats either version alone, because compression already handles repeated keys.

  • Minify before sending payloads over bandwidth-constrained links.
  • Keep a formatted copy in the repository for readability; minify at build time.
  • Do not minify tokens or signatures that depend on exact byte sequences.

What minification preserves

Numbers keep their original textual representation as parsed and re-serialized by JSON.stringify. Note that 1.0 becomes 1, and 1e3 becomes 1000, because the parser normalizes numbers. Key order is preserved for string keys, except integer-like keys, which JavaScript reorders numerically.

If byte-for-byte fidelity matters, minify with a tool that operates on tokens rather than parsing and re-serializing.

Minified JSON is not smaller on disk if it is stored with compression already; the real win is fewer characters over the wire and faster parsing in some clients.