sort json keys alphabetically
put every object in your json into alphabetical key order, at all depths, so two versions of a file line up and compare cleanly.
runs on your device · free · no sign-up
loading tool…
how to sort json keys alphabetically
- paste your json into the box, or press sample to try it out.
- if it is invalid, read the line and column message and press jump to error to land on the problem.
- pick an indent, minify it, or turn on sort keys, then switch between text and tree view.
- type a path such as $.users[*].name to pull out values, then copy or download the result.
sorting is useful before committing a config or translation file, because two people adding keys in different places stop causing merge conflicts. run both versions through the same sorter and a diff tool shows only the real changes.
only object keys are reordered. arrays keep their order because the position of an item is part of the data. keys are compared in plain code point order, so uppercase letters come before lowercase and numbers sort as text, which is the same result most json libraries produce.
more ways to json formatter
frequently asked questions
are arrays sorted too?
no. array items stay in their original order, because order is meaningful there. only the keys inside objects are sorted, including objects nested inside arrays.
is the sort case sensitive?
yes. it uses plain character order, so "Zebra" comes before "apple". this matches the default of most programming languages and tools.
can i sort in reverse order?
not here. the tool always sorts a to z. for a reverse order, copy the result into a text editor with a sort lines feature.