Beautify vs format
"Beautify" and "format" usually mean the same thing: re-indenting JSON so it is readable. This page adds the style controls people want when the result goes into a repository, a README or a ticket — indent width from 1 to 8 spaces or tabs, alphabetised keys, and "compact short arrays", which keeps arrays of plain numbers or short strings on one line like [1, 2, 3] instead of one item per line.
Sorted keys plus a fixed indent give a canonical layout: two files with the same data produce identical text, so a git diff only shows real changes.
Frequently asked questions
Is beautified JSON still valid JSON?
Yes. Only insignificant whitespace between tokens changes. Any parser reads the beautified and minified versions as exactly the same data.
Does sorting keys change the meaning?
No. JSON objects are unordered by definition (RFC 8259), so key order carries no meaning. Array order does matter and is never changed.
What indentation should I use?
Use what your codebase already uses. 2 spaces is the most common for JSON in JavaScript projects (package.json, tsconfig.json); 4 spaces is common in Python projects.
Can I beautify JSON with comments?
Not here — comments are not part of JSON. Remove them first; the validator will find each one.