JSON Sorter

Runs in browser JSON & Data

Recursively sort object keys ascending or descending so that two documents with the same content produce identical text. Perfect for snapshot tests and configuration files.

Privacy: This tool runs entirely in your browser. Your input never leaves your device.
Loading tool…

How to use JSON Sorter

  1. Paste the JSON whose keys you want to normalise.
  2. Pick A → Z or Z → A and the indentation style.
  3. Copy the canonical result into your config, fixture or snapshot.

JSON Sorter features

  • Recursively sorts object keys ascending or descending
  • Keeps array order untouched
  • Locale-aware, case-insensitive ordering
  • Choose indentation for the output, including minified
  • Live output with copy and download

JSON Sorter example

Canonicalise a fixture

Input:

{"zeta":1,"alpha":{"y":true,"x":false}}

Output:

{
  "alpha": {
    "x": false,
    "y": true
  },
  "zeta": 1
}

Frequently asked questions about JSON Sorter

Are nested objects sorted too?

Yes. Keys are sorted recursively at every level, including objects inside arrays.

Does sorting change arrays?

No. Array order carries meaning, so items keep their positions; only object keys are reordered.

Why sort keys at all?

Sorted keys give a canonical representation. Two documents with the same content become byte-identical, which is ideal for snapshot tests, cache keys, config files and clean git diffs.

How is the order decided?

Keys are compared with locale-aware, case-insensitive ordering (A → Z or Z → A), so "Beta" sorts between "alpha" and "gamma".