JSON Key Sorter
Sort the keys of every JSON object alphabetically, ascending or descending, at all nesting levels. Array order is kept, and you pick the indent of the output.
Use the tool
Why this tool exists
Two JSON files can hold identical data and still look completely different because their keys come in another order. That makes diffs noisy, code reviews slow and version control history hard to read. Sorting keys first gives you a stable, predictable layout.
Typical moments are comparing an API response before and after a change, committing a generated config file, or hashing a document where key order would otherwise change the result. The tool sorts every object in the document, however deep, and leaves arrays in their original order because their order carries meaning. Parsing and sorting happen in your browser, so your data is not uploaded.
How to use it
- Paste your JSON into the input box.
- Choose ascending or descending order.
- Choose the indent: 2, 4, 8 spaces or a tab.
- Copy the sorted JSON.
Frequently asked questions
Are arrays sorted too?
No. Array items keep their order, because order in an array is usually meaningful. Only the keys of objects are sorted, though objects inside arrays are sorted as well.
How are keys compared?
Keys are compared as plain strings by character code, so uppercase letters sort before lowercase ones. A and B come before a and b.
Does sorting change the meaning of the JSON?
No. JSON objects are unordered by definition, so parsers read the sorted and unsorted versions as the same data. Only the text layout changes.
Is it the same as the Sort keys option in the formatter?
It does the same ascending sort, and adds a descending option. Use the formatter if you also want to check errors, or this tool when sorting is the main job.