Skip to content

JSON Sorter

Sort JSON keys alphabetically.

Loading…

About JSON Sorter

Two config files can hold identical settings and still produce a wall of changes in a diff, simply because the keys were written in a different order. Paste a JSON document and every object, however deeply nested, gets its keys in ascending order, with two spaces of indentation. Arrays keep their order, since reordering them would change the data, and values are not changed.

Features

  • Sorts the keys of every nested object, not just the top level
  • Array items keep their original order
  • Plain code-unit order, so 10 sorts before 2 and uppercase before lowercase
  • Repeated keys are kept rather than merged
  • Output indented with two spaces and updated live

Limitations

  • Ascending order only: there is no descending, case-insensitive or natural number sort.
  • Array items are never reordered, even when they are objects you might want sorted by a field.
  • The indentation is fixed at two spaces, and the original layout is not kept.
  • Downloading the result needs a free account; copying it does not.

How it works

  1. Paste the JSON into the JSON Input panel.
  2. Read the Sorted JSON panel, which updates as you type and lists the keys of every object in ascending order.
  3. If the text is not valid JSON, an error message appears in the middle column instead.
  4. Select Copy Output to copy the result, or Download to save it as output.txt.

Example input

{
  "zebra": 1,
  "apple": 2,
  "mango": { "banana": 1, "avocado": 2 }
}

Frequently asked questions