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.
How to use JSON Sorter
- Paste the JSON whose keys you want to normalise.
- Pick A → Z or Z → A and the indentation style.
- 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
- RFC 8259: The JavaScript Object Notation (JSON) Data Interchange FormatThe JSON grammar: objects, arrays, strings, numbers, the three literals, and UTF-8 as the interchange encoding.
- ECMA-404: The JSON Data Interchange SyntaxThe JSON syntax as an Ecma standard, kept in step with RFC 8259.
- Introducing JSONThe original one-page description of JSON with its railroad diagrams.