Why pretty-printing matters more than it looks
A minified API response is correct but unreadable — one 40 KB line where a missing field could hide anywhere. Formatting re-serializes the same data with consistent indentation so structure becomes visible: nesting depth reads as horizontal position, siblings align, and a missing brace announces itself. Because the formatter parses and re-emits rather than editing text, the output is guaranteed-valid JSON with exactly the same data; only whitespace changes.
Sort keys when files live in version control
JSON objects have no guaranteed key order, so two serializations of identical data can produce a noisy git diff. Recursively sorting keys A→Z makes serialization deterministic: config files, lockfile-style manifests, and API fixtures diff cleanly commit after commit. Sorting only reorders object keys — array order is data, so arrays are left exactly as they are.