JSON Sorter
Paste JSON to sort its keys alphabetically, at every nesting level or just the top one. You can also sort arrays by their values or by a field such as name or price, and get the result pretty-printed or minified.
How to use the JSON Sorter
- Paste your JSON into the input box, upload a .json file or try the sample.
- Choose the key order: A to Z, Z to A or keep the original order, and whether nested objects are sorted too.
- Sort arrays if needed: by value, or by a key of the objects inside them (pick it from the list or type a path like
user.name). - Pick the output style: 2 spaces, 4 spaces, tabs or minified.
- Copy or download the sorted JSON. The result updates automatically as you type.
Example: sorting keys and an array by key
| Input | Keys A → Z, recursive | + array sorted by price |
|---|---|---|
{"b": 1, "a": {"z": 0, "y": 0}, "list": [{"price": 9}, {"price": 3}]} |
{"a": {"y": 0, "z": 0}, "b": 1, "list": [{"price": 9}, {"price": 3}]} |
{"a": {"y": 0, "z": 0}, "b": 1, "list": [{"price": 3}, {"price": 9}]} |
Sort order rules
- Ignore case on:
apple, Banana, cherry. When two keys differ only by case, the uppercase one comes first so the result is always the same. - Ignore case off: plain character-code order, where all uppercase letters come before lowercase:
Banana, apple, cherry. This matchesjq -S, Python'ssort_keys=Trueand most "canonical JSON" tools. - Natural numbers on:
file1, file2, file10. Off:file1, file10, file2. - Arrays by value: nulls first, then booleans (false before true), numbers in numeric order, strings, and finally nested arrays and objects in their original order.
- Arrays by key: objects missing the key are moved to the end. Sorting is stable, so items with equal keys keep their original relative order.
When sorted JSON helps
Sorted keys make JSON deterministic: the same data always produces the same text. That is what you want for version-controlled config files (package.json scripts, translation files, OpenAPI specs), for snapshot tests, and before comparing two documents with a diff tool, where differences in key order would otherwise hide the real changes. Note that JSON object key order carries no meaning, but array order does, so only sort arrays when their order does not matter, such as lists of tags or lookup tables.
Frequently asked questions
Why sort JSON keys?
The order of keys in a JSON object has no meaning to parsers, but a stable alphabetical order makes files easier to read, produces cleaner diffs in Git, and lets you compare two API responses or config files line by line.
Does sorting change my data?
No. Sorting keys only changes the order in which properties are written, and objects are equal regardless of key order. Sorting arrays does change meaning, because array order is significant, so it is off by default and must be switched on.
What is natural sort order?
Natural order compares runs of digits as numbers, so item2 comes before item10. Plain character order would put item10 first, because the character 1 sorts before 2.
How are arrays with mixed types sorted?
Values are grouped by type in this order: null, false/true, numbers, strings, then arrays and objects, which keep their original relative order. Numbers are compared numerically and strings alphabetically.
Will big numbers lose precision?
No. The sorter uses its own parser that keeps every number exactly as written, so IDs like 12345678901234567890 and decimals like 1.10 are not rounded or reformatted, which a plain JSON.parse would do.
What happens with duplicate keys?
They are kept. Duplicate keys are allowed by the JSON grammar, so the sorter keeps both entries next to each other in sorted order and shows a warning, since most parsers keep only the last value.
Is my JSON uploaded?
No. Parsing and sorting run in JavaScript in your browser, so your data never leaves your device.