How to use the JSON key sorter
- Paste your JSON into JSON.
- Pick the Order: A → Z or Z → A.
- Leave Ignore case ticked for dictionary order, or untick it for strict character order.
- Tick Also sort arrays of plain values if lists such as tags or allowed hosts should be sorted too.
- Choose an Indent (2 spaces, 4 spaces, tabs or none) and copy or download the Sorted JSON.
What it does and when to use it
Different programs write the same data with keys in a different order. A diff of two API responses, two exported settings files or two lock files then shows dozens of moved lines that are not real changes. Sort both documents with the same settings and the diff shows only what actually changed. It also helps when you keep JSON fixtures or translation files in Git and want new keys to land in a predictable place.
After sorting, compare the two versions with JSON diff, which also ignores key order on its own. To see every key path in a large document, use the JSON key extractor; for indentation alone, the JSON formatter has a simpler “Sort keys A–Z” option.
How it works
The JSON is parsed in your browser and rebuilt from the top down. At each object, the key list is sorted and the object is rebuilt in that order. With Ignore case, keys are compared with English locale rules at base strength, so case and accents are ignored and ties fall back to character code order. The result is printed with JSON.stringify at your chosen indent.
One JavaScript rule shows through: integer-like keys such as "2" and "10" are always placed first, in numeric order, because that is how JavaScript objects store them. The same happens in any JavaScript-based tool.
Worked examples
A small package.json, minified output:
{"version":"1.0.0","name":"app","scripts":{"test":"vitest","build":"vite build","Dev":"vite"},"keywords":["z","a"]}
{"keywords":["z","a"],"name":"app","scripts":{"build":"vite build","Dev":"vite","test":"vitest"},"version":"1.0.0"}
The nested scripts keys are sorted too, and keywords keeps its order. With Ignore case off, scripts becomes {"Dev":"vite","build":"vite build","test":"vitest"}.
With Also sort arrays of plain values ticked, {"tags":["b","A","c"],"nums":[10,9,100],"items":[{"z":1,"a":2}]} gives:
{"items":[{"a":2,"z":1}],"nums":[9,10,100],"tags":["A","b","c"]}
Limits and tips
- Very large integers and long decimals pass through
JSON.parse, so integers above 2^53 may change. Keep such IDs as strings. - Comments are not allowed. Clean them up with JSON repair first.
Frequently asked questions
Does sorting keys change what the JSON means?
Why does item10 come before item2?
What does "Ignore case" change?
Are arrays of objects sorted too?
Does it keep duplicate keys?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.