JSON Sorter
Sort JSON keys alphabetically.
JSON Sorter – Sort JSON Keys Alphabetically
The JSON sorter orders the keys of your JSON objects alphabetically, at the top level or recursively through every nested object. Choose ascending or descending order, case-sensitive or case-insensitive comparison, and optionally sort the values of simple arrays as well.
Why sort JSON keys?
- Cleaner diffs – when two services or two versions of a file emit keys in different orders, a diff shows every line as changed. Sorting both first leaves only the real differences. Combine it with JSON Diff for a structural comparison.
- Stable snapshots – tests that compare serialized JSON stop failing because of random key order.
- Readable configuration – finding
timeoutin a 200-line config is easier when keys are alphabetical, much like a sortedpackage.json. - Canonical form – hashing or signing JSON requires a deterministic representation; sorted keys are the first step.
Options explained
- Order – A → Z or Z → A.
- Sort nested objects – when on, every object at every depth is sorted, including objects inside arrays. When off, only the top-level keys move.
- Ignore case – compares keys in lowercase, so
Authorsits next toauthor. - Sort arrays of values – sorts arrays that contain only primitive values. Numbers are compared numerically, strings alphabetically. Arrays of objects keep their order.
The data itself never changes: values stay attached to their keys and the output is valid JSON in the indentation you choose.
Related tools
Format without sorting in the JSON Beautifier, or drop empty fields first with the JSON Cleaner.
Frequently Asked Questions
Does sorting keys change the meaning of JSON?
No. JSON objects are unordered by definition, so reordering keys never changes the data. Arrays are ordered, which is why sorting array values is a separate, opt-in switch.
How are uppercase and lowercase keys ordered?
By default the sort is by character code, so uppercase letters come before lowercase ones ("Author" before "name"). Turn on “Ignore case” for a dictionary-style order.
Which arrays are sorted with 'Sort arrays of values'?
Only arrays that contain nothing but strings, numbers, booleans, or null. Numbers are sorted numerically. Arrays of objects are left in their original order, because there's no single correct key to sort them by.
Why would I want sorted JSON?
Sorted keys give stable, predictable output: diffs between versions only show real changes, snapshots in tests stop flapping, and humans find keys faster in large configuration files.