JSON Key Sorter
Sorts every object key in a document alphabetically, recursively, so diffs stay stable.
Loading the tool…
Processing happens locally in your browser.
What you paste or load is processed by this page and is not uploaded to a server. Nothing is stored unless you use a control that says it stores something, and you can clear anything this site has kept from the privacy page.
How to use this tool
- Paste the document.
- Select Sort keys.
- Commit the canonical form so future diffs show only real changes.
What json key sorter does
Key order carries no meaning in JSON, but it makes a large difference to tooling that does not know that. A serialiser that emits keys in insertion order will produce a different file every time the code changes, and the version control diff will be full of movement rather than change.
Sorting keys recursively gives a canonical form. Two documents that hold the same data will then produce the same text, which makes them safe to commit, to checksum, and to compare with an ordinary line diff. Array order is left alone, because in an array order usually does mean something.
Frequently asked questions
No. Object key order carries no meaning in JSON, and every conforming parser produces the same value regardless of order.
So that the same data always produces the same text. That makes documents safe to commit to version control, to checksum, and to compare with an ordinary line diff.
No. Array order usually is meaningful — a list of steps, a ranking, a sequence of events — so sorting it would change the data. Only object keys are reordered.