How to Sort JSON Keys Alphabetically (Free, No Sign-Up)
10/15/2026 • json, how-to, sort, developers
Two JSON files holding the same data in different key order look completely different to a diff tool — every line flags as changed. Sorting keys alphabetically makes the comparison honest: real differences stand out, and identical data diffs clean.
Use the free tool: JSON Formatter — includes the "Sort keys (deep)" option.
Steps
-
Open the JSON Formatter.
-
Paste your JSON into the editor.
-
Choose the Sort keys (deep) option.
-
Copy the sorted output.
What "deep" means, and why arrays stay put
Sorting is recursive: keys are alphabetized at every level of nesting, not just the top level. Arrays, though, are never reordered — array order is data. A list of steps, tags, or coordinates means something different in shuffled, so the tool leaves arrays exactly as they are and sorts only object keys.
This is the step people reach for when comparing two config files, tidying up translation and i18n files so translators can find keys, cleaning up a messy package.json, or diffing two API responses that return keys in different orders.
Troubleshooting
- Invalid JSON? Sorting needs valid JSON — fix syntax errors first. See how to fix common JSON errors.
- Arrays look unchanged? That's correct — arrays are never reordered, only object keys.
- Uppercase keys sort before lowercase ones? That's normal. Sorting follows character order, so capital letters come before lowercase ones.
Next steps:
Frequently asked questions
Is sorting JSON keys free?
Yes — free and unlimited, with no account required.
Does sorting change my data?
No — it only reorders keys. Values, types, and array order stay exactly the same.
Are nested objects sorted too?
Yes — sorting is deep (recursive), so keys at every level of nesting are alphabetized.
Do arrays get reordered?
No. Arrays keep their original order — only object keys are sorted, since array order is meaningful.