JSON Sorter — Sort JSON Keys Alphabetically
Recursively sort every key in your JSON object alphabetically. Useful for normalizing exports, generating deterministic snapshots, and reducing Git diffs.
Output will appear here…Sort JSON keys at every depth
JSON objects are unordered by definition, but in practice every parser preserves the insertion order of keys. That is convenient most of the time — you can put the most important fields at the top of a response, for example — but it also means the same logical object can produce two different byte sequences depending on which code path produced it. Sorting the keys recursively makes the representation deterministic, which has practical benefits for diffs, caching, and snapshot testing.
Lintify walks your JSON document and sorts every object's keys alphabetically. Arrays are left untouched, because arrays are ordered by definition — [1,2,3] and[3,2,1] are genuinely different documents. Only object keys are sorted. You can choose between case-sensitive and case-insensitive sorting from the toolbar.
Why sorted keys matter for version control
When two developers independently update the same JSON config file, the diff that Git shows depends on key order. If both developers added keys at the end of the file (in the order they happened to think of them), Git will show many lines changed even though only a few keys were actually added. Sorting the keys before committing eliminates this noise — the diff becomes the real diff, not an artifact of insertion order.
The same logic applies to snapshot testing. If your test runner captures a JSON response and compares it to a stored snapshot, key order changes will produce spurious failures. Sorting the keys before snapshotting makes the test robust to insertion order, so it only fails when the actual data has changed.
Sorting and stable hashing
If you hash a JSON document to detect changes — for HTTP ETag headers, cache keys, or change-detection pipelines — you need a stable byte representation. Without sorting, the same logical object can produce different hashes depending on how it was constructed in memory. Sorting the keys first guarantees that two objects with the same keys and values produce the same hash, regardless of insertion order.
Case sensitivity
By default, Lintify sorts case-sensitively, which matches how JavaScript compares strings — uppercase letters sort before lowercase because their character codes are lower. This meansApple comes before apple, which may or may not be what you want. Toggle to case-insensitive sorting from the toolbar if you want Apple andapple to sort adjacent to each other.
Frequently asked questions
Common questions about the Sorter tool.