Sort JSON Keys
Put the keys of every object in a JSON file into alphabetical order, however deeply nested. Great for tidy configs and clean diffs. Runs on your device.
- No email required
- Stays on your device
- Sorts every level
- Array order unchanged
- Runs on your device. Files are never uploaded.
- Free and unlimited. No sign-up, no watermark.
JSON key sorter in three steps
No account, no email, no waiting for an upload.
- STEP 01
Drop in your JSON
Use the text box or load a .json file.
- STEP 02
Pick indent and escaping
Choose 2 spaces, 4 spaces or tabs. Optionally write non-ASCII characters as \u codes.
- STEP 03
Copy the sorted JSON
Every object now has its keys in A to Z order. Download it or copy it.
What JSON key sorter does, and what it doesn't
We'd rather tell you up front than surprise you after the download.
What you get
- Recursive sortingKeys are sorted in the top-level object and in every nested object.
- Arrays are left aloneList items keep their order, because order in a list usually carries meaning.
- Stable, repeatable outputThe same data always produces the same text, which keeps version-control diffs small.
- Exact numbersLarge IDs and decimals are printed back exactly as written.
- Errors with a positionInvalid JSON stops with the line and column of the problem.
Good to know
- Sorting uses character codesCapital letters come before lowercase, so Zebra sorts before apple. If you want case ignored, use the sort choice in the JSON formatter.
- Duplicate keys collapseIf a key appears twice in one object, the last value is kept.
- Only objects are sortedTo order the items of a list by a field, you would need a script or a spreadsheet. See JSON to CSV and CSV sorter.
Your data never leave your device
The tool runs inside your browser instead of on our servers, so there is nothing to upload, store or delete afterwards.
Typical online tool upload
Your file travels over the internet, sits on someone else's computer for a while, and you wait for the upload and the download.
Mediaextractr no upload
The tool loads into your browser once, then works on your file locally. Nothing is sent, so nothing can leak.
When people use JSON key sorter
Make diffs readable
Sort two versions of a file and compare them without key-order noise.
Normalize a config
Keep package or settings files in a predictable order in your repo.
Compare for equality
Produce a canonical-looking text before you hash it with the hash generator.
Review a large object
Find a key faster when the list is alphabetical.
Mediaextractr vs typical upload tools
| MediaextractrPrivate | Typical upload tools | |
|---|---|---|
| Your file is uploaded | Never | Yes |
| Sign-up needed | No | Often, after a few files |
| Daily file limit | None | Often 1–2 free files |
| Watermark | Never | Sometimes |
| Wait for upload & download | No | Yes |
| Speed on very large files | Depends on your device | Depends on their servers |
How the order is decided
Keys are compared by their character codes, the same simple rule used by many programming languages. Digits come first, then capital letters, then lowercase letters. A key named Zip therefore sorts ahead of address.
Numeric-looking keys are treated as text here, so 10 comes before 2. If you rely on numeric order, you will need to check those keys by eye.
Where sorted keys help
Sorted JSON is easier to scan and much easier to compare. A few places it pays off:
- Committing generated JSON, so reruns do not create noise.
- Reviewing two files in JSON diff or JSON compare.
- Making sure two exports with different key order are really identical.
- Preparing a lookup file that people will read by hand.
Before you sort
Sorting never changes values, only the order of keys inside objects. Programs that read JSON by key name will see the same data. A program that depends on key order, which the JSON standard does not guarantee, may behave differently.
Questions, answered
How do I sort JSON keys alphabetically?
Paste your JSON and copy the result. Every object's keys come out in A to Z order.
Does it sort nested objects too?
Yes. All levels are sorted. Arrays keep their order, though objects inside arrays have their keys sorted.
Is a config with keys and secrets sent to a server when sorted?
No. Sorting is done by code in this tab. Your file is never posted anywhere.
Why does a capital letter come before a lowercase one?
Keys are compared by character code, where capitals come first. For a case-insensitive order use the JSON formatter's sort option.
Will my numbers change?
No. Numbers are written exactly as they were in your source.
Does sorting work on iOS and Android browsers?
Yes. Current mobile versions of Safari and Chrome handle it like a desktop browser.