JSON Sorter Online
Sort the top-level keys of a JSON object into alphabetical order. Nothing leaves your device.
Your result appears here.
What the sorter does
The tool parses your JSON object, takes its list of keys, sorts that list with the default JavaScript string comparison, and rebuilds the object in the new order. It then pretty-prints the result with two-space indentation. The comparison is by UTF-16 code unit, which means it is case-sensitive: uppercase letters sort ahead of lowercase, and digits sort ahead of letters. Values are never touched, and only the outermost object's keys are reordered.
Why sort keys
A deterministic key order makes JSON files behave well in version control: two people editing the same config produce a minimal diff instead of a reshuffle. It also makes two objects easy to compare by eye, helps you find a key quickly in a large object, and gives generated output a stable shape for snapshot tests. Many teams alphabetize package.json-style dependency blocks and environment dumps for exactly this reason.
Worked example
Input:
{"name": "x", "age": 3, "Active": true, "id": 42}
Output:
{
"Active": true,
"age": 3,
"id": 42,
"name": "x"
}
"Active" comes first because its capital A outranks every lowercase letter.
Sort order reference
| Key group | Code point range | Sorts |
|---|---|---|
Digits 0-9 | 48–57 | First |
Uppercase A-Z | 65–90 | Second |
Lowercase a-z | 97–122 | Third |
FAQ
Can I get case-insensitive sorting?
Not on this page. If you need it, lowercase the keys in your editor before sorting, or sort in code with localeCompare.
What if the input is a JSON array, not an object?
Arrays have no keys to sort, so the tool returns the array unchanged and formatted.
Are duplicate keys handled?
The parser keeps the last value for a repeated key before sorting, so duplicates collapse.
Is anything uploaded?
No. It runs entirely in your browser.