JSON Sort Keys

Paste JSON and get it back with the keys of every object in alphabetical order. Arrays keep their order unless you ask, because the order of list items usually means something. Sorted JSON is easier to scan and gives clean diffs when two systems write the same data in a different key order.

Action

Changes data order; off by default.

JSON
Result

Processing runs in your browser. What you type never leaves this device.

Features

  • Sorts keys at every level, or only the top

  • A to Z or Z to A

  • Natural order (item2 before item10), ignoring case

  • Optional sorting of lists of plain values

  • 2 or 4 spaces, tab or minified output

  • Line and column for JSON errors

Why sort JSON keys

Clean diffs

Sort both files before comparing them in the [diff checker](/tools/diff-checker); only real changes remain.

Config files and translations

Keep package.json scripts, i18n files and feature flags in a predictable order so merges conflict less.

Stable signatures and caches

Some signing and caching schemes need one canonical key order; sorting gives the same text for the same data.

Sorting rules

What changes and what does not

  • Object keys are reordered; values are untouched.
  • Arrays keep their order. Turn on "sort lists of plain values" only for lists such as tags, where order does not matter.
  • Default order compares character codes, so capitals come before small letters (B before a). Natural order ignores case and reads numbers as numbers.

JSON Sort Keys - FAQ