Validate & Format · Runs in your browser

Sort JSON Keys

Sort every object’s keys alphabetically, at every level of nesting, so two versions of a document line up cleanly in a diff.

Paste, drop or type your JSON

It’s checked as you type — nothing is uploaded.

Ctrl + V to paste · drop a .json file anywhere here

Drop your JSON file to load it
Waiting for input1 line0 B

Ctrl Enter ValidateCtrl Shift F FormatCtrl Shift M MinifyCtrl Z Undo

How to use it

  1. Paste your JSON or upload a .json file.
  2. Click “Sort keys”. Every object, however deeply nested, is reordered A–Z.
  3. Copy or download the result. Ctrl + Z restores the original order.

Arrays keep their order

Only object keys are sorted. Array items stay where they are, because their position usually carries meaning.

Stable diffs

Serializers often write keys in a different order each time. Sorting both versions first makes a text diff show only real changes — or use JSON Diff, which ignores key order entirely.

Duplicate keys

If an object contains the same key twice, you’re warned before sorting, because only the last value can be kept.