Sort JSON

Input
Output

Sort JSON Keys Alphabetically

Sorting JSON keys alphabetically makes documents predictable and far easier to scan, diff and review. MyJson’s sorter reorders the keys of every object — recursively through nested structures — while leaving array order and values untouched.

Consistent key order is especially valuable in version control: two JSON files with identical data but different key order produce noisy diffs, and sorting eliminates that noise.

How to use the sort json

  1. 1Paste your JSONDrop in the JSON whose keys you want ordered.
  2. 2Choose a directionSort ascending (A–Z) or descending (Z–A).
  3. 3Enable recursive sortingSort keys inside nested objects too, not just the top level.
  4. 4Copy the sorted resultCopy the normalised JSON for committing, comparing or storing.

Features

  • Ascending (A–Z) or descending (Z–A) ordering
  • Recursive sorting through nested objects
  • Array element order is preserved
  • Values are never modified, only key order

When to use it

  • Normalising JSON before committing to reduce diff noise
  • Making large config files easier to scan
  • Preparing two files for a clean comparison
  • Producing deterministic JSON output

Frequently asked questions

How do I sort JSON keys alphabetically?

Paste your JSON and choose ascending or descending order. MyJson reorders every object’s keys instantly. Enable recursive mode to sort nested objects as well.

Does sorting change my data?

No. Only the order of object keys changes. Values, data types and the order of array elements are all preserved exactly.

Why sort JSON keys?

Consistent key order makes JSON easier to read and produces clean, meaningful diffs in version control when the underlying data is unchanged.

Related tools

Looking to learn more? Browse our JSON guides and tutorials.