JSON Sorter – Sort JSON Keys Online

Sort the keys of your JSON from A to Z or Z to A, at every level. Great for comparing and reviewing JSON.

JSON Input

Ln 1, Col 1Empty

Sorted JSON

Your result will appear here.
No result yet

What Is a JSON Sorter?

A JSON sorter puts the keys of every object in alphabetical order. Sorted JSON is easier to read, makes changes easy to spot in Git, and gives you the same key order every time, which is perfect before comparing two files.

How to Sort JSON

  1. Paste your JSON, click Upload, or drop a .json file on the box.
  2. Choose A to Z or Z to A.
  3. Click Sort JSON, or press Ctrl + Enter.
  4. Click Copy or Download to save the sorted JSON.

Features

  • Sorts keys at every level, including objects inside arrays.
  • Natural order, so "item2" comes before "item10".
  • Keeps array order, with an option to sort simple arrays too.
  • Fixes small JSON mistakes automatically before sorting.
  • Runs in your browser. Your JSON is never uploaded.

Example

Before
{ "zip": "SW1A", "item10": 1, "Name": "Emily", "item2": 2, "age": 30 }
After (A to Z)
{
  "age": 30,
  "item2": 2,
  "item10": 1,
  "Name": "Emily",
  "zip": "SW1A"
}

Sorting ignores upper and lower case, so Name sits between item10 and zip, and numbers inside keys are compared as numbers, so item2 comes before item10.

Why Sort JSON Keys?

  • Cleaner Git diffs: when every file uses the same key order, a diff only shows real changes, not keys that moved around.
  • Easier comparing: sort two files before comparing them by eye. (The JSON Compare tool already ignores key order.)
  • Finding keys fast: in a config with dozens of settings, alphabetical order makes each one easy to find.
  • Translation files: keeping language files like en.json and de.json in the same order makes missing keys obvious.

Does Key Order Matter in JSON?

No. The JSON standard says an object is an unordered set of keys, so sorting never changes what the data means. Array order is different: [1, 2, 3] and [3, 2, 1] are different values, which is why arrays keep their order unless you turn on sorting for simple arrays. Need one level of keys instead of nesting? Use JSON Flatten.

Sort keys in code
json.dumps(data, sort_keys=True, indent=2)   # Python, every level
jq -S . data.json                            # command line, every level

Frequently Asked Questions

What does a JSON sorter do?

It puts the keys of every JSON object in alphabetical order, from A to Z or Z to A, at every level. The values stay the same.

Why sort JSON keys?

Sorted keys make JSON easier to read, easier to compare in Git or a diff tool, and make it simple to spot missing or duplicate fields.

Are arrays sorted too?

Array order is kept by default, because order matters in arrays. You can turn on the option to also sort simple arrays of text or numbers.

Is my JSON uploaded?

No. Sorting happens in your browser and your data never leaves your device.

Related Tools