JSON Key Sorter
Sort object keys alphabetically for canonical JSON and cleaner diffs. 100% local.
Why Sort JSON Keys?
JSON objects are unordered by spec, but most tools and humans impose their own ordering. Sorting keys alphabetically produces canonical JSON — a deterministic representation where any two logically identical objects serialize to the same string. This matters for content hashing, code review, and debugging because you can compare two JSON files and trust that differences reflect real data changes, not incidental reorderings.
Sorted JSON also produces dramatically cleaner version-control diffs. When a new key is added or an existing value is updated, only those lines appear in the diff — not a block of unrelated key reorderings from the serializer.
{
"zebra": true,
"apple": 1,
"mango": {
"zucchini": "z",
"avocado": "a",
"broccoli": ["c", "b", "a"]
},
"banana": null
}{
"apple": 1,
"banana": null,
"mango": {
"avocado": "a",
"broccoli": ["c", "b", "a"],
"zucchini": "z"
},
"zebra": true
}["c", "b", "a"] inside mango.broccoli is preserved exactly as-is. Array element order is meaningful and is never changed by this tool.Recursive vs. Shallow
The tool offers two sorting modes. Recursive sorting is almost always what you want; use shallow only when you intentionally need to preserve the order of nested objects (e.g., a priority-ordered plugin configuration).
| Mode | What it sorts | When to use |
|---|---|---|
| Recursive (default) | Top-level keys and all nested object keys at every depth | Canonical JSON, content hashing, stable diffs |
| Shallow | Top-level keys only; nested object key order is preserved | When nested key order is intentional and must be kept |
Try It
Frequently Asked Questions
Your files stay on your computer. Dad promised.