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…

What is JSON?

JSON (JavaScript Object Notation) is a text format for structured data built from objects, arrays, strings, numbers, booleans and null. It is defined by RFC 8259 and ECMA-404, is language-independent, and is the default format of web APIs because it is compact, human-readable and easy to parse.

Read the guide: What is JSON?

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
  • Case-insensitive alphabetical ordering with one fixed collation, whatever the browser language
  • 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 alphabetically and case-insensitively with one fixed (English) collation, not your browser's language, so the order does not change with the device language, and "Beta" sorts between "alpha" and "gamma". Z → A is the exact reverse. Keys made of digits are compared as text, so "10" sorts before "9".

References