About the JSON Sorter
JSON objects are unordered by definition, but text diff tools compare line by line, so two documents with the same data and different key order look completely different. Sorting keys gives every document a canonical form. This tool sorts the keys of every object, optionally recursing into nested objects and arrays, and re-serialises with your chosen indent.
Array order is never changed, because in JSON the position of an item in an array is meaningful. Only object keys are reordered. Sorting is case-sensitive using locale-aware comparison, so Zebra sorts after apple only if you consider case, which most tooling does; the result is stable across runs.
Use it before committing a lock file or configuration to version control, before diffing two API responses with the Diff Checker, or to make a settings file easier to scan.
How to use
- Paste JSON on the left.
- Pick A to Z or Z to A. Untick Sort nested objects to sort only the top level.
- Copy or download the sorted result.
Common questions
- Does the sorter change the order of items inside arrays?
- No. Array order carries meaning in JSON, so it is left exactly as you provided it. Objects inside arrays are still sorted when the nested option is on.
- Are numbers in keys sorted numerically?
- Keys are compared as text, so "10" sorts before "9". Zero-pad numeric keys if you need natural order.
- Why sort JSON at all?
- To get a canonical form that diffs cleanly, hashes consistently and is easier to read. Many package managers sort their lock files for the same reason.