Sort JSON Keys Alphabetically
Sorting keys makes JSON output deterministic so two equivalent objects serialise identically. Pretty-print your object in the tool below, then apply the ordering rules described here.
Why sort keys at all
JSON object keys are unordered, so the same data can serialise in different orders. Sorting keys alphabetically makes the output canonical: the same object always produces the same text. That gives you stable git diffs, reproducible cache keys, and easy comparisons.
Sort recursively
Sort keys at every level, not just the top. A nested object should have its own keys sorted too, so the whole document is deterministic top to bottom.
What not to reorder
Only object keys are safe to sort. Never reorder array elements — array order is meaningful in JSON, and shuffling it changes the value.
FAQ
Does sorting keys change the data?
No. Object keys are unordered in JSON, so alphabetising them produces the same value with a canonical, reproducible serialisation.
Should I sort array items too?
No. Array order is significant. Sort only object keys; leave arrays exactly as they are.
Why do this before committing config?
A canonical key order keeps git diffs small and meaningful — you see the value that actually changed instead of reordered keys.