use case
How to sort JSON keys alphabetically
Reorder all keys in a JSON object alphabetically at every level of nesting for consistent diffs and readability.
Alphabetically sorted JSON keys make git diffs cleaner, make config files easier to scan, and let you reliably compare two JSON objects by eye. When keys are added in random order over time, a sorted snapshot reveals exactly what changed. This guide shows how to sort all keys in a JSON object — recursively, at every level of nesting — using the quickhelp.dev JSON Formatter.
Step-by-step guide
- Paste your JSON: Open quickhelp.dev/json-formatter and paste the JSON whose keys you want to sort.
- Enable Sort Keys: Toggle on the 'Sort keys' option. Leave mode set to 'Pretty' for readable output.
- Copy the sorted result: Click Run then Copy. The output has every object's keys sorted A→Z at every depth.
Frequently asked questions
- Does sort order affect JSON semantics?
- No. JSON objects are unordered by specification — key order carries no semantic meaning. Sorting is purely a style convention.
- Are array elements also sorted?
- No. Array elements maintain their original order because arrays are ordered by definition.
Try it now
Use the JSON Formatter to complete this task — free, no sign-up, runs in your browser.
Open JSON Formatter →