Code Beautify / MULTIVERTO

Sort JSON keys

Alphabetize object keys recursively without changing array order.

Live converterYour input stays in this browser. No text is uploaded for conversion.

The file stays in your browser.
Chain tools

Apply each text tool to the previous result. Text workflows ↗

Only the recipe name and tool order are saved in this browser. Your input and results are never saved.

01 / Example

Example

Your input{"z":"Welcome","a":{"z":"Hello","a":true}}
Result{ "a": { "a": true, "z": "Hello" }, "z": "Welcome" }

02 / Guide

Sort JSON keys — How it works

What the conversion does

Alphabetize object keys recursively without changing array order. Parse JSON, sort each object’s member names, and indent the result.

Worked example

The sample input is {"z":"Welcome","a":{"z":"Hello","a":true}}; its converted form is { "a": { "a": true, "z": "Hello" }, "z": "Welcome" }.

Format rules and limits

This operation parses JSON rather than sorting lines of text. Every object is visited recursively and its member names are placed in JavaScript lexicographic order; array elements stay in their original positions because array order usually has meaning. Values keep their JSON type, including true, false, null and numbers. Indentation changes so the output can be reviewed, but numeric spelling and insignificant whitespace may differ from the source. JSON object key order is often semantically irrelevant to applications, although order can matter to diffs, snapshots and protocols that sign exact bytes. Do not use this output as a canonical JSON signature format. Duplicate member names in the source are resolved by the JSON parser before sorting, so inspect such data in a dedicated parser if retaining every occurrence is essential. Compare API fixtures whose object members arrived in different orders while preserving the sequence of array items. Key sorting starts only after JSON parsing, so an unquoted integer outside ±9,007,199,254,740,991 is rejected before any keys move. Store an exact identifier in quotes; changing member order cannot make an unsafe number precise.

Check the result

For JSON key sorting, parse the output again and compare its data with the parsed input, rather than comparing the original bytes. Check that arrays kept their order and that every object was sorted, including objects nested inside arrays. If the result will be signed or hashed, use the exact canonicalization required by that protocol instead of assuming alphabetical keys are sufficient. Nest an object inside an array with deliberately reversed keys; inspect both the outer and inner object while confirming that array positions did not move. Compare parsed values before and after sorting, with special attention to arrays: their element order must stay intact while object members are reordered. Inspect nested objects too, because sorting only the root would leave unstable diffs. The resulting indentation is for reading and is not a canonical signature format. If another system signs JSON bytes, obtain that system’s canonicalization rule before hashing this output. Also investigate duplicate names in the source separately; ordinary JSON parsing may already have discarded one before the sort begins. Keep the unsorted source until the receiving parser accepts the output. Sorting object names in this browser does not remove credentials or private values; review those fields before committing the JSON to a repository.

How this conversion transforms the input
JSON — Input
Read and transform structure
JSON — Result