JSON

JSON Sort Keys

Recursively sort JSON object keys alphabetically — array element order is left untouched, only object keys at every nesting level.

JSON doesn't guarantee object key order, so two semantically identical documents can look different simply because their fields are in a different order. This tool recursively sorts object keys alphabetically at every nesting level, without touching array element order.

How to use it

Common uses

Things to keep in mind

Sorting is byte-based (by Unicode code point) — all uppercase letters come before lowercase ones regardless of alphabet, unlike locale-aware sorting.

Only object keys are sorted — array element order carries semantic meaning in JSON, so it's never changed.

Article about this tool: JSON Sort Keys: why sort an object's keys

Frequently asked questions

Why would I sort JSON keys?

Sorted keys make it easier to diff two versions of a JSON document and make configuration files or API responses more predictable when browsing them.

Does this change the order of array elements?

No. Only object keys are sorted at every nesting level — array element order is left exactly as it was in the input, since arrays are ordered by position, not by keys.

Is the data processed on a server?

No, sorting happens entirely in your browser via JavaScript, with nothing sent anywhere else.

Are keys sorted recursively at every nesting level?

Yes, sorting applies not only to the top-level keys but to the keys of every nested object at any depth — otherwise the result would be inconsistent.

Does language or locale affect the order of sorted keys?

Byte-based sorting (by Unicode code point) puts all uppercase letters before lowercase ones regardless of alphabet. This differs from locale-aware sorting, which orders letters the way a human would expect — the difference is unnoticeable for most technical keys, but worth keeping in mind for non-Latin names.

Articles: JSON