>_devtools

JSON Sort Keys

Sort JSON object keys alphabetically at every level, ascending or descending, with array order preserved.

What this does

Reorders the keys of every JSON object alphabetically, at all levels or only the top one, ascending or descending. Array items stay in their original order, because order in an array carries meaning.

Sorted JSON is the quickest way to make two documents comparable line by line, to keep generated config files stable in version control, or to find a key in a long object.

Comparison modes

  • Exact compares UTF-16 code units, so uppercase letters sort before lowercase. It is deterministic everywhere.
  • Ignore case sorts apple, Banana, cherry the way people expect; keys that differ only by case are ordered by exact value so the result is still stable.
  • Natural puts item2 before item10 by comparing digit runs as numbers.

Numeric-looking keys

Browsers' built-in JSON.stringify always lists integer-like keys such as "2" and "10" first, no matter how an object was sorted. This tool writes the JSON itself, so keys land exactly where the sort puts them.

Notes

Numbers are read as standard double-precision values, so integers beyond 253 lose precision, as in every JavaScript JSON tool. A repeated key keeps only its last value.

Example

Input:

{"zebra":1,"apple":{"mango":true,"banana":false},"list":[{"b":1,"a":2}]}

Result:

{
  "apple": {
    "banana": false,
    "mango": true
  },
  "list": [
    {
      "a": 2,
      "b": 1
    }
  ],
  "zebra": 1
}

Privacy

Everything runs in your browser. Your input is never uploaded, stored, or put in the page URL.