Input

Output

Formatted result will be displayed here

Why sort JSON keys?

Sorting JSON keys alphabetically gives you a deterministic representation, which is useful any time you need to compare two JSON documents, hash them, or commit them to version control without spurious diffs. This tool sorts keys at every level of nesting, leaves arrays in their original order, and preserves all values untouched. The result is the same data in a canonical form.

Use Cases

Stabilize git diffs

Normalize JSON fixtures so reordering a field in one service does not produce a noisy diff in unrelated tests.

Compare two JSON objects

Sort both sides first, then run a text diff and every real difference jumps out without key-order noise.

Produce canonical hashes

Hashing JSON only makes sense over a canonical form; sorting keys is the simplest canonicalization step.

Clean up hand-edited configs

Contributors tend to append new keys at the bottom. A sort pass puts everything back in a predictable order.

FAQ

Does it sort arrays too?

No. Array order is semantic, so the tool leaves arrays alone. Only object keys are sorted.

How does it handle case?

Sort order is lexicographic using the default string comparison, which means uppercase letters come before lowercase. Normalize case beforehand if that matters.

Is sorted JSON still valid?

Yes. The JSON spec does not require any particular key order, so sorting is always safe from a parser standpoint.

What about duplicate keys?

Duplicate keys are not valid JSON and will be flagged during parse. Only the last occurrence survives most parsers, but you should fix the source.