Sort JSON object keys alphabetically (recursively), sort array values, or both — ascending or descending, with object arrays sortable by any key. Sorted JSON diffs cleanly.
Show calculation steps
Processed privately in your browser — nothing you paste is uploaded, logged or stored.
Canonical order for readable diffs
The same data serialized twice with different key order looks like a wall of changes in any diff tool. Sorting keys alphabetically — recursively, at every level — gives JSON a canonical form: the same data always prints the same way. Arrays can be sorted too, but only when you say so, because array order often carries meaning.
Worked example
Keys mode:
{"zebra":1,"apple":2,"mango":{"b":1,"a":2}}becomes:
{
"apple": 2,
"mango": { "a": 2, "b": 1 },
"zebra": 1
}When to use it
- Before comparing two documents — sort both, then the JSON Compare report shows real differences only.
- Keeping config files in stable, review-friendly order.
- Sorting arrays of records by a field (enter the key name) for readable exports.
Limitations to know
- Key order is semantically meaningless per RFC 8259, so sorting is safe for machines — but if some consumer displays keys in file order, the display order will change.
- Arrays of objects only sort when you provide the sort key; mixed-type arrays sort by string comparison.
Common errors and fixes
- Object arrays did not sort — enter the field in “Sort object arrays by key”; without it the tool refuses to guess and says so in a warning.
- Positions matter in my data — then sort keys only (the default) and leave arrays alone.
How to use the JSON Sorter
- Paste your JSON into the input panel.
- Choose what to sort — object keys, array values, or both — and the direction.
- For arrays of objects, enter the key to sort by (for example: name).
- Click "Sort JSON" and copy the result.
Frequently asked questions
Why sort JSON keys alphabetically?
Two big reasons: diffs and comparisons become meaningful (the same data always serializes the same way), and large objects become scannable because every key has a predictable place. Sort both documents before comparing and the noise disappears.
Does key order matter in JSON?
Per RFC 8259 an object is unordered — parsers must not care. But tools that compare TEXT (git diff, checksums, caches) care very much, which is why canonical key order is so useful.
How are arrays of objects sorted?
Enter a key name in "Sort object arrays by key" and arrays whose elements all have that key sort by its value — numbers numerically, strings alphabetically. Without a key, object arrays keep their order, because guessing a sort field would be wrong more often than right.
Is sorting arrays safe?
Only you can know: [1,2,3] as a set of IDs sorts safely, but coordinates, steps or rankings encode meaning in their positions. That is why array sorting is opt-in rather than the default.