Skip to main content
Back to tools

JSON Sort Keys

Sort JSON object keys alphabetically, recursively

About JSON Sort Keys

Returns your JSON with the keys of every object, at any depth, sorted alphabetically and pretty-printed with two-space indentation, updating as you type. Parsing relies on the browser's JSON engine, so numbers are normalized (1.50 becomes 1.5), integers beyond 2^53 - 1 lose precision and duplicate keys keep only their last value. Handy before committing config files or diffing API responses.

Category: Converters.

Frequently asked questions

Why sort JSON keys?

▾

Sorted keys make diffs cleaner — when two JSON files have the same keys in different orders, a sorted version produces minimal diffs. It also makes large objects easier to scan manually.

Is the sort case-sensitive?

▾

Yes. Keys are compared by character code, so uppercase letters come before lowercase (A < Z < a < z) and symbols such as _ fall in between. There is no case-insensitive option.

Does it sort nested objects too?

▾

Yes. The sort is applied recursively — all nested objects at any depth have their keys sorted as well, including objects inside arrays. The order of array elements is never changed.

Why do numeric keys such as 2 and 10 appear first?

▾

JavaScript objects always list integer-like keys first, in ascending numeric order, so they come before all other keys and 2 precedes 10 even though an alphabetical sort would put 10 first.

Related tools