JSON Key Sorter
Reorder the keys of every JSON object alphabetically to get a stable, canonical document.
Processed locally in your browser/ Your data stays in your browser.
What is JSON Key Sorter?
JSON objects are unordered by specification, but in practice their key order shows up in diffs, hashes, snapshots and code reviews. Sorting keys produces a canonical form: two documents with the same content end up as identical text.
This tool sorts the keys of every object, at all depths or only at the top level, in ascending or descending order. Arrays are never reordered (their order carries meaning), although objects inside arrays are sorted. Numbers are copied verbatim, so large integers and spellings like 1.50 survive.
How does it work?
- Paste your JSON into the input area.
- Choose ascending or descending order and decide whether nested objects should be sorted too.
- Pick an indentation, or compact output if you want a single line.
- Copy the sorted document or download sorted.json.
Common use cases
- Making two configuration files comparable in a plain text diff.
- Producing a stable snapshot for tests and version control.
- Canonicalising a payload before hashing or signing it (together with the minifier).
- Finding a key quickly in a large object by reading it alphabetically.
Examples
Try this input in the tool above:
{"name":"Ada","zip":"N1","address":{"street":"Main","city":"London","apt":3},"list":[{"z":1,"a":2},{"y":true,"b":false}],"age":36}{
"address": {
"apt": 3,
"city": "London",
"street": "Main"
},
"age": 36,
"list": [
{
"a": 2,
"z": 1
},
{
"b": false,
"y": true
}
],
"name": "Ada",
"zip": "N1"
}Privacy
JSON Key Sorter runs entirely in your browser. The text or files you provide are processed on your device and are not uploaded, logged or stored on our servers.
Limitations
Sorting compares keys by UTF-16 code units (so uppercase letters come before lowercase ones), not by language-specific collation. Duplicate keys are kept.
Frequently asked questions
Are arrays sorted as well?
No. The items of an array keep their order because order is meaningful there. Only the keys of objects (including objects nested in arrays) are sorted.
Why do uppercase keys come first?
Keys are compared by character code, and every uppercase ASCII letter has a lower code than any lowercase one. This is the same order as a default JavaScript sort and is deterministic across machines.
Does sorting change any values?
No. Only the position of keys changes. Values, numbers and strings are copied exactly as written.
Related tools
JSON Formatter & Beautifier
Turn a minified or messy JSON document into readable, consistently indented text, with a precise error message if the JSON is invalid.
JSON & Data
JSON Diff – Compare Two JSON Documents
Paste two JSON documents and see what changed in the data, regardless of key order or indentation.
JSON & Data
JSON Minifier
Compress a JSON document to one compact line and see how many bytes you saved.
JSON & Data
JSON Validator
Check whether a piece of text is valid JSON and locate the exact character where it goes wrong.
JSON & Data
JSON Viewer
Explore a JSON document as an expandable tree instead of a wall of text, with a summary of its structure.
JSON & Data
YAML Formatter & Beautifier
Re-indent and normalise a YAML file while keeping comments, anchors and multi-document structure.
JSON & Data