JSON Sorter Online 2026 - Alphabetize JSON Keys for stable Git Diffs
Alphabetize JSON keys to make Git diffs stable and meaningful. Fix unstable diffs in package.json and locale files—100% client-side, your code never leaves your browser.
Key Features
- ✅ Alphabetical key sorting
- ✅ Recursive sorting
- ✅ Stable Git diffs
- ✅ Data integrity preservation
- ✅ Client-side only
How to Use
- Accept JSON input via textarea or file upload
- Parse JSON using JSON.parse()
- Recursively traverse and sort object keys alphabetically at every nesting level
- Preserve array order (do not sort arrays)
- Preserve value types and data integrity
- Output sorted JSON with consistent indentation
- All logic is client-side; no data leaves the browser
- Support case-sensitive vs locale-aware sort modes
Expert FAQ
- Does this actually change the meaning of my JSON, given that JSON object key order isn't guaranteed anyway?
No — the JSON spec doesn't define object key order as meaningful, so any conforming consumer treats {"a":1,"b":2} and {"b":2,"a":1} identically. Sorting is purely for the humans and diff tools reading the source text, not for anything a JSON parser cares about; the practical exception is code relying on JS engines' de-facto insertion-order iteration, which sorting will change the iteration order of even though it doesn't change the data's meaning. - Why leave arrays unsorted specifically?
Because array order is very often semantically meaningful — a migration script's ordered steps, a list of ranked search results, an ordered enum of allowed values — and array element order is part of the JSON spec's actual data model, unlike object key order. Reordering an array would be a data change, not a cosmetic one, so this tool deliberately never touches array contents, only object key ordering. - Does it sort case-sensitively — does "Zebra" come before or after "apple"?
By default it uses standard string comparison, which is case-sensitive (uppercase letters sort before lowercase in ASCII, so "Zebra" sorts before "apple"). A locale-aware, case-insensitive sort option is available for cases like alphabetizing a locale/translation file where you want human alphabetical order rather than byte-value order. - Will this break a JSON Schema or API contract that depends on key order?
It shouldn't, if the schema/contract is spec-compliant — object key order isn't part of JSON Schema's validation model. If some downstream system does depend on literal key order (a genuinely non-compliant but real-world scenario, sometimes seen in hand-rolled parsers or certain legacy XML-derived JSON), sorting would break that dependency, since it's relying on behavior the JSON spec never guaranteed in the first place.
Technical Details
Unsorted, inconsistently-ordered JSON keys in package.json, locale/translation files, or generated configuration create noisy Git diffs: two developers adding keys in different orders produce a diff dominated by reordering rather than the actual content change, and merges become harder to review than they should be. Since the JSON specification never defines object key order as semantically meaningful — any conforming parser treats differently-ordered-but-otherwise-identical objects as equal — alphabetizing keys is a purely cosmetic, meaning-preserving transformation from the spec's point of view, even though it does change iteration order for code that happens to rely on JavaScript engines' de-facto insertion-order behavior. Array contents are deliberately never reordered, because array element order is part of JSON's actual data model and is very often meaningful — an ordered list of migration steps, ranked results, or a defined enum sequence would have its actual meaning changed by resorting, unlike object keys. This is a hard boundary the sorter respects at every nesting level: only object key order is normalized, recursively, through the entire document. String comparison for sorting defaults to standard (case-sensitive, ASCII-order) comparison, with an optional locale-aware, case-insensitive mode for cases like alphabetizing human-readable translation keys where byte-order sorting (which puts all uppercase letters before all lowercase ones) doesn't match intuitive alphabetical order. After sorting, the JSON Compare tool produces a genuinely clean diff against a previous version, since key-order noise is eliminated before comparison, and JSON Pretty Print can improve on-screen readability further.