Sort JSON Keys Alphabetically

Recursively sort the keys of a JSON object A→Z or Z→A in your browser, with array order left untouched. Your JSON stays local.

Sort JSON Keys runs entirely in your browser. The JSON you paste is parsed and re-serialized on your device, and nothing is uploaded to ArrayKit.

Open the JSON Formatter

About Sort JSON Keys

Sort JSON Keys reorders the keys of every object in a JSON document into alphabetical order, top to bottom and all the way down into nested objects. Arrays keep their element order — only object keys move — so the data is identical, just canonically ordered. Choose A→Z or Z→A, turn on case-insensitive compare so Name and name group together, and set the indent to 2 spaces, 4 spaces, or a tab. Sorted keys make two config files or API payloads diff cleanly, help you spot a missing field, and give you a stable canonical form for snapshots and cache keys. It is built for developers wrangling settings files, fixtures, and API responses. Everything runs in your browser, so the JSON you paste never leaves your device.

Features

How to use the Sort JSON Keys

  1. Paste your JSON into the input box
  2. Pick A→Z or Z→A and set the indent width
  3. Turn on case-insensitive compare if you want mixed-case keys grouped
  4. Copy the sorted JSON or download it as a .json file

Example

Input

{ "name": "Ada", "id": 42, "roles": ["author", "admin"] }

Output

{
  "id": 42,
  "name": "Ada",
  "roles": [
    "author",
    "admin"
  ]
}

Keys are alphabetized while the roles array keeps its original order.

Common errors & troubleshooting

Frequently asked questions

Does sorting JSON keys change the data?
No. Sorting only reorders the keys inside objects; every key, value, and array element is preserved. The result parses to the same data — it is just written in a canonical, alphabetical order.
Are the keys of nested objects sorted too?
Yes. Sort JSON Keys walks the whole document recursively, so keys in nested objects and in objects inside arrays are all alphabetized, not just the top-level keys.
Does sorting keys reorder the items in an array?
No. Array order often carries meaning, so array elements keep their original positions. Only object keys are reordered; each object inside an array still gets its own keys sorted.
How does case-insensitive key sorting work here?
With case-insensitive compare on, keys are ordered ignoring letter case, so Name and name sit next to each other. With it off, uppercase keys sort before lowercase ones, which is the default JSON string order.
Why would I want to alphabetize JSON keys?
A canonical key order makes two JSON files diff cleanly, exposes missing or duplicate fields, and gives stable snapshots and cache keys. It also makes large config files far easier to scan by eye.
Is my JSON uploaded when I sort the keys?
No. Sort JSON Keys runs entirely in your browser. The JSON you paste is parsed, sorted, and re-serialized on your device, and nothing is sent to ArrayKit.

Related tools

All ArrayKit tools