JSON Key Sorter
Sort JSON object keys alphabetically or naturally, at every level or just the top, and sort arrays of objects by a field.
Local workspace
Named projects in IndexedDB · Local only — never synced to our servers. Worksp…
Batch workspace
Format multiple files locally in one run.
Options
| Option | Description |
|---|---|
| Order | Code point order compares Unicode values, so uppercase keys come first. Natural order ignores case and compares embedded numbers by value. |
| Descending | Reverses the order. Also applies to arrays sorted by a field. |
| Depth | All levels sorts every nested object. Top level only sorts the root object, or each record in a root array, and leaves nested objects as they are. |
| Sort arrays by | Sorts arrays of objects by this field or dotted path. Numbers compare by value, and objects without the field go last. Leave empty to keep array order. |
| Indent | Formatting of the sorted output. |
FAQ
Why sort JSON keys?
Sorted keys make two versions of a document line up, so diffs, code reviews, and snapshot tests show only real changes instead of reordering noise.
What's the difference between code point and natural order?
Code point order compares characters by their Unicode number, so uppercase sorts before lowercase and file10 comes before file2. Natural order ignores case and compares numbers by value, so file2 comes before file10.
Why do numeric keys like "10" and "2" keep the order I chose?
JavaScript engines always move integer-like keys to the front of an object, which silently breaks most sorters. This tool writes the output text itself, so keys appear exactly in the order you picked.
Can I sort an array of objects by a field?
Yes. Enter a field name such as id, or a dotted path such as user.name, in 'Sort arrays by'. Numbers sort by value, and items without the field go last.
Does sorting change any values?
No. Only key order changes, and array order changes only when you choose a field to sort by. Values, types, and nesting stay the same.