JSON pretty-print vs minify: which output to use
Pretty-print JSON for reading and logs, or minify whitespace for APIs and storage. Same data, different wrapping.
Pretty-print inserts newlines and indent so a diff and a code review stay readable. Minify strips whitespace so a payload is smaller on the wire. Parsers treat both as the same document if the tokens match.
Pretty for anything a human will open. Minify for localStorage, fixtures in a build, and responses you will not read. Mixing them in git produces noisy diffs; pick one style per file and keep it.
Neither mode “fixes” invalid JSON. Validate first. Repair is a separate toggle for trailing commas, not a substitute for a correct payload.
Pretty-print is for reading and for a diff. Minify is for a request body or a file you pay to store. They are the same data if the parse succeeds. A minify that also sorts keys will make a noisy diff against a file that kept insertion order. Keep the pretty form in git if humans edit it. This page is the choice; the converter runs either mode.
| Trait | Pretty-print | Minify |
|---|---|---|
| Whitespace | Newlines and indent | Stripped between tokens |
| Human reading | Diffs and reviews | Not meant to be read |
| Use | Source and logs | APIs, localStorage, generated blobs |
FAQ
Does minify change numbers?
No. Only insignificant whitespace between tokens.
Which for git?
Pretty, unless the file is a generated one-line blob you never read.
