JSON Object Formatter
Format a JSON object with its keys in alphabetical order at every level of nesting, two spaces to an indent. The page opens with sorting already on and an example object loaded, so you can see what it does to nested objects before you paste your own. Arrays are left exactly as written, because the order of an array is data and reordering it would change what the document says.
Formatted
Common questions
- How are the keys ordered?
- A to Z, case-insensitively, at every level. Comparing without case means Name and age come out in the order a person expects rather than in code-unit order, where every capital letter sorts before every lowercase one. When two keys are the same apart from case, they keep the order you wrote them in, so a document containing both B and b is not silently rearranged twice. Escaped names are compared after decoding, so \u0061 sorts as a, while its original escape remains in the output. This is not a cryptographic canonicalization algorithm.
- Does sorting touch arrays?
- No. Array elements stay in the order you wrote them, because in JSON that order is meaning: the first item of a list is the first item. Objects inside an array are each sorted internally, so a list of records comes out with consistent field order while the records themselves stay in sequence.
- Does sorting change my values?
- No. The sort moves whole members around in the token stream rather than parsing the document into an object and printing it back out. Your number literals are copied character for character, so a 20 digit ID keeps all 20 digits, and strings keep their exact escapes. Nothing is rounded, retyped or re-encoded.
- Why would I want keys sorted?
- Mostly to make two documents comparable. Config files and API responses that differ only in key order produce a diff full of noise, and sorting both sides first reduces it to the changes that matter. It is also a quick way to find a key in a long object, and to spot two keys that are nearly the same name.
- Can I turn it off?
- Yes, with Keys → As written. The key choice applies to both Formatted and Minified output, and Copy uses the selected output. Arrays keep their original order in either mode.
- What if the JSON does not parse?
- You get the mistake named, with a line and column, and nothing is sorted: there is no reliable order to impose on a document whose structure is not yet known. Fix the reported line and the sorted output appears. Switch Show to Verdict to put the pass or fail message at the top of the pane.
Formatting and minification preserve original string and number tokens. Object keys stay as written unless sorting is enabled; sorted keys are compared by decoded name, without case, while array order stays unchanged. Syntax checking is separate from schema validation.