deftools.io Developer Tools

JSON Key Sorter

Sort JSON object keys alphabetically or in a custom order. Deep recursive sort for stable snapshots before diffing or committing.

0 chars

One key per line. Matching keys appear first, then the rest A to Z.

0 chars

About this tool

Sort the keys of any JSON object alphabetically (A to Z or Z to A), recursively through every nested object. This is especially useful before committing configuration files to version control — stable key order makes git diff meaningful instead of noisy reordering noise.

Example: {"b":2,"a":1} sorted A to Z becomes {"a":1,"b":2}. With deep sorting enabled, keys inside nested objects are sorted too: {"c":{"z":26,"y":25},"a":1} becomes {"a":1,"c":{"y":25,"z":26}}.

Use the custom key priority field to pin important keys to the top — for instance, put id, name, and type first, then let the rest follow alphabetically. This is handy for API response schemas where specific keys carry primary meaning and should always appear first in diffs and reviews.

FAQ

Why sort JSON keys?

Sorted keys produce deterministic output — the same JSON input always produces the same output byte for byte. Essential for commit-friendly config files and API snapshot testing.

How is this different from the JSON Formatter sort checkbox?

The Formatter sort is a convenience toggle for top-level keys. The JSON Key Sorter gives you full control: recursive deep sort, custom key priority lists, array element sorting, and A to Z or Z to A direction.

What does the custom key priority do?

Paste one key name per line (e.g. id, name, type). Those keys appear first in the output in the order listed. Remaining keys follow alphabetically.

Does this sort array elements too?

Only when you check Sort array elements. Arrays of primitives are sorted; arrays of objects are left in their original order because reordering objects changes their meaning.

More developer tools

Copied!