Input
- Size
- 0 B
- Lines
- 0
- Keys
- 0
- Depth
- 0
Stable key order makes Git diffs smaller
JSON object key order does not change the data, but it does change the text. Two payloads with the same keys in a different order produce a noisy diff. Sorting every object the same way, in this browser, gives you a predictable file before you commit.
A–Z and Z–A
A–Z compares keys with JavaScript string order and writes the smaller key first. Z–A reverses that order. Changing the menu sorts the current JSON again. Nested objects are sorted at every level. An array keeps its index order, and objects inside that array are still sorted.
Example
Before: {"zeta":1,"alpha":{"name":"Ada","city":"Quetta"}}. After A–Z: alpha comes before zeta, and inside alpha the key city comes before name. The result is formatted JSON you can copy or download as formatted.json.
Sort keys here, then open Compare two JSON files when you want the semantic diff. The formatter on the homepage still beautifies without sorting.
Frequently Asked Questions
Does sorting JSON keys upload the file?
No. The sort runs on the parsed value in this browser. A local .json file is read with FileReader and is not sent to a server.
Are nested object keys sorted?
Yes. Every object is sorted, including objects nested inside other objects and objects stored in arrays.
Does array order change?
No. Arrays stay in index order. Only object keys are reordered. Objects inside an array still have their own keys sorted.
What is the difference between A–Z and Z–A?
A–Z writes keys in ascending JavaScript string order. Z–A writes the same keys in the reverse order. Switching the menu sorts the current JSON again.
Why sort keys before a Git diff?
A formatter or API can emit the same object with keys in a different order. Sorting both sides the same way keeps the diff focused on values that actually changed.