Sort JSON keys

Sorting JSON keys: when it helps

Sorting object keys alphabetically can make comparisons and code reviews significantly easier.

What sorting changes (and what it doesn’t)

Example

Before:

{"z":1,"a":2,"b":{"y":1,"x":2}}

After sorting:

{"a":2,"b":{"x":2,"y":1},"z":1}

When it’s safe

When to be careful

Related: Compare JSON · Pretty print JSON