JSON Key Sorter
Paste JSON and get the same data with its keys in order. Large numbers keep every digit, numbers like 1.0 keep their form, and the order of list items is left alone.
Worked examples
Sorted with exact numbers
{"b":1.0,"a":{"z":12345678901234567890,"y":2}}
{ "a": { "y": 2, "z": 12345678901234567890 }, "b": 1.0 }
The long number and 1.0 are unchanged.
About JSON Key Sorter
Sorted keys make JSON easier to read, easier to compare and steadier in version control. Two files with the same content but a different key order look completely different to a line by line comparison, and sorting both removes that noise so the real changes show up.
This sorter changes nothing except the order of the keys. Numbers are copied exactly as written, so a very large ID keeps all its digits and a value such as 1.0 stays 1.0 instead of becoming 1. Keys that look like numbers stay in the order you choose, rather than jumping to the front as they do in some tools. Lists keep their item order because that order usually means something. You can sort A to Z or Z to A by character code, ignore capitals, or use natural order so that item2 comes before item10, and you can limit the sort to the top level.
How to use JSON Key Sorter
- Paste your JSON. A mistake is reported with a line and column.
- Choose ascending or descending order and how to compare keys.
- Choose the indent, and whether to sort nested objects as well.
- Copy the sorted JSON.
Common uses
- Making config files diff cleanly
- Comparing two API responses
- Keeping a translation file in order
- Producing stable fixtures for tests
Frequently asked questions
Does sorting change the meaning of the JSON?
No. The order of keys in an object has no meaning in the standard, so sorting does not change the data. Lists are never reordered.
Why do some tools put numeric keys first?
JavaScript objects order keys that look like whole numbers before others, whatever you do. This tool reads the keys itself, so the order you choose is the order you get.
Are my numbers changed?
No. They are copied as written, including large integers beyond the range that ordinary numbers hold exactly, trailing zeros and exponents.
What is natural order?
Numbers inside keys are compared as numbers, so a2 comes before a10, where plain order puts a10 first.
Can I sort only the top level?
Yes. Untick the nested option and only the keys at the top are sorted.