Dad’s Data formats tools

JSON Key Sorter

Sort object keys alphabetically for canonical JSON and cleaner diffs. 100% local.

JSON Input
Sorted Output
Paste JSON to sort its keys alphabetically.

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.

Unsorted → Sorted (recursive)
Input
{
  "zebra": true,
  "apple": 1,
  "mango": {
    "zucchini": "z",
    "avocado": "a",
    "broccoli": ["c", "b", "a"]
  },
  "banana": null
}
Output
{
  "apple": 1,
  "banana": null,
  "mango": {
    "avocado": "a",
    "broccoli": ["c", "b", "a"],
    "zucchini": "z"
  },
  "zebra": true
}
Note: Notice that the array value ["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).

ModeWhat it sortsWhen to use
Recursive (default)Top-level keys and all nested object keys at every depthCanonical JSON, content hashing, stable diffs
ShallowTop-level keys only; nested object key order is preservedWhen nested key order is intentional and must be kept

Try It

Interactive — edit the input to see the output update
Try it
Result

Frequently Asked Questions

Your files stay on your computer. Dad promised.

Data formats tools

Search the Data formats tools