Sort JSON keys
Sort nested JSON object keys alphabetically with a live preview while keeping array order intact.
How it works & useful details
How it works
Sort every object’s keys using case-sensitive UTF-16 lexical order. Numeric-looking keys are sorted as text, so “10” comes before “2”. Array elements retain their order. This is a key sorter, not a canonicalization or signing implementation.
Limits & privacy
Up to 1,000,000 characters, 50,000 values and 64 levels. Live previews pause above 40,000 characters; run the tool to process the full supported input. Imported files must be UTF-8 and under 1 MB. Your data stays on this device.
Numbers use JavaScript decimal precision. Unsupported large integers are rejected; quote identifiers to keep all digits. Duplicate object names keep their last value. Transforms preserve data, not source whitespace or number spelling.
Paths use JSON Pointer: an empty path selects the root, ~0 escapes a tilde, and ~1 escapes a slash.
About this tool
Sort JSON keys rewrites nested objects with their keys in alphabetical order while leaving array order untouched. It is a quick way to make configuration files and API payloads easier to diff and review.
The sort is stable and structural: only object keys move, never array elements or values. Everything happens locally, with a live preview of the sorted document.
How to use it
- Paste the JSON document.
- Run the sort and compare against the preview.
- Check that arrays kept their original order.
- Copy or download the sorted JSON.
Worked example
{"zebra":1,"apple":{"size":"small","color":"green"},"mango":3,"banana":2}sorted in ascending order becomes
{
"apple": { "color": "green", "size": "small" },
"banana": 2,
"mango": 3,
"zebra": 1
}Nested objects are sorted too, while arrays keep their element order, because reordering an array changes its meaning.
Why sort keys
Sorted keys make diffs meaningful. Two configuration files, translation files, or API snapshots with the same content but different key order become textually identical, so version control and review tools show only real changes. Sorted files are also easier to scan by eye, and merge conflicts become less likely when teammates add keys.
Order is case-sensitive and based on UTF-16 code units, which is the same as JavaScript's default sort. Uppercase letters sort before lowercase ("Zebra" before "apple"), and numeric keys sort as text ("10" before "2"). Sorting is not full canonicalization. Signing or hashing JSON reliably requires a standard such as RFC 8785 (JCS), which also fixes number and string formatting.
Frequently asked questions
Are array elements reordered?
No. Array order is meaningful data, so only object keys are sorted.
How are numeric-like keys handled?
Keys are compared as strings, so 10 sorts before 2 just as it would in a sorted list of names.
What is the limit?
Up to 1,000,000 characters, 50,000 values, and 64 levels of nesting.
Does sorting change any values?
No. Only the order of object keys changes. Values, arrays, and nesting stay the same.
