About the JSON Sorter
Sort the keys of every object in your JSON alphabetically, ascending or descending. Sorted JSON is easier to read, review and compare.
Key features
- Sort object keys A→Z or Z→A
- Sorts recursively through every nested object
- Natural ordering: key2 comes before key10
- Array order is preserved (arrays are data, not keys)
- Choose 2-space, 4-space or tab output
- Instant, private, no upload
Why sort JSON keys?
JSON objects are unordered by definition, but people still read them in order. When two systems serialize the same data with keys in a different order, comparing them becomes painful. Sorting keys alphabetically gives every document a canonical order, which makes reviews, diffs and lookups much easier.
Example
{ "zip": "N1", "name": "Ada", "address": { "street": "1 Way", "city": "London" } }
sorted A→Z:
{
"address": {
"city": "London",
"street": "1 Way"
},
"name": "Ada",
"zip": "N1"
}
Great uses for a JSON sorter
- Cleaner Git diffs. Commit config files with sorted keys and only real changes show up in diffs.
- Comparing API responses. Sort both before comparing them; better still, use JSON Compare, which ignores key order automatically.
- Translation files. i18n files like
en.jsonare much easier to maintain alphabetically. - Code review. Reviewers find fields faster in alphabetical order.
- Deterministic output. Hashing or signing JSON requires a stable key order.
How sorting works
- Every object at every level has its keys sorted using natural, locale-aware ordering.
- Arrays keep their original element order, but objects inside arrays are sorted too.
- Values are never modified.
| Input keys | A→Z result |
|---|---|
b, a, C | a, b, C |
item10, item2, item1 | item1, item2, item10 |
_id, id, Id | _id, id, Id |
Tip: sorting for canonical JSON
For signing or hashing, you usually need sorted keys and no whitespace. Sort here, then run the result through the JSON Minifier.
Related tools
Sort, then format or validate. To reorder lines of plain text, use Sort Text Lines.
How to use the JSON Sorter
- Paste your data into the input box, upload a file, or click Sample to try it out.
- Adjust the options above the editor if you need to (indentation, delimiter, and so on).
- The result appears instantly in the output panel. Any errors are shown with their line and column.
- Click Copy to copy the result, or Download to save it as a file.