Sort JSON Keys Online.
Sort JSON keys alphabetically A to Z or Z to A. Reorder nested object keys recursively, preserve arrays by default, optionally sort arrays, and export clean formatted JSON.
No signup · No uploads · Recursive key sorting
Sorted JSON output
Sort JSON keys alphabetically
A sort JSON keys tool reorders object properties so JSON output is easier to scan, compare, review, and commit. Paste JSON above, choose A to Z or Z to A, and the tool outputs valid JSON with sorted keys. It runs entirely in your browser, so private data never leaves your device.
How to sort JSON keys in three steps
- Paste JSON into the input or load the sample.
- Choose sort options - A to Z, Z to A, recursive nested keys, and array handling.
- Sort and export - copy the result or download sorted JSON.
Recursive nested JSON sorting
Most real JSON has nested objects. With recursive sorting enabled, the JSON key sorter sorts keys inside every object, not just the top level. That makes API responses, package metadata, translation files, configuration files, and test fixtures more stable and easier to review in diffs.
Preserve arrays or sort arrays too
Array order often has meaning, so this tool preserves arrays by default. If you intentionally want deterministic array order, choose Sort arrays too. Objects inside arrays can still have their keys sorted recursively while the array items stay in their original order.
Key order carries no meaning — that is why sorting is safe
The JSON specification defines an object as an unordered set of name/value pairs. These two documents are the same object, and every parser will agree:
{ "name": "Ada", "role": "admin", "id": 1 } { "id": 1, "name": "Ada", "role": "admin" } Sorting keys rewrites the text without touching the data. It is always safe.
The real payoff: diffs that mean something
Two services serialise the same object with keys in different orders — one
uses a hash map, the other preserves insertion order. Nothing has changed,
but git diff paints the whole file red and green and code review
becomes useless.
Sort both sides first and the noise disappears; only genuine changes remain. Sorting also makes JSON deterministic, which matters when you are checksumming a payload, using it as a cache key, or committing a lockfile that should not churn on every install.
For a one-off comparison you do not even need to sort — the JSON diff tool compares structurally and ignores key order for you.
Sort keys in code
# Python — sort_keys handles nesting automatically
import json
print(json.dumps(data, sort_keys=True, indent=2)) # Command line
jq -S . data.json > sorted.json
JavaScript has no built-in equivalent — JSON.stringify follows
insertion order — so you have to rebuild each object with sorted keys
recursively. That is one reason a tool is handy.
Be careful sorting arrays
Object keys are unordered; array items are not.
[1, 2] is genuinely a different value from [2, 1],
so sorting an array does change your data.
Only sort arrays that truly represent unordered sets — tags, permissions, scopes, feature flags. Never sort ranked results, ordered steps, or a time series.
Why sort JSON keys?
Sorted JSON is useful when you want stable Git diffs, readable config files, normalized API examples, or deterministic generated output. You can combine this page with JSON Formatter for readable indentation, JSON Minifier for compact output, or JSON Diff to compare two normalized JSON files. Learn more in the guide on how to sort JSON keys.
FAQ
Sort JSON keys, answered.
How do I sort JSON keys online? +
Paste your JSON into the JSON Sort tool, choose A to Z or Z to A, and press Sort JSON Keys. The tool parses the JSON, reorders object keys, and outputs valid sorted JSON.
Can it sort nested JSON keys recursively? +
Yes. Recursive nested keys is enabled by default, so object keys are sorted at every level of the JSON document. You can turn it off when you only want to sort top-level keys.
Can I sort JSON keys from Z to A? +
Yes. Choose Z to A to sort keys in reverse alphabetical order. Choose A to Z for the standard alphabetical JSON key sort.
Does sorting JSON keys change values? +
No. Sorting object keys changes only the order of properties in the output. Strings, numbers, booleans, null, objects, and arrays keep their values.
Can it sort arrays inside JSON? +
Yes, but arrays are preserved by default because array order often has meaning. Choose Sort arrays too when you intentionally want array values reordered.
Is my JSON uploaded when sorting keys? +
No. Sort JSON keys runs entirely in your browser. Your data is never uploaded, stored, logged, or sent to a server.
Why would I sort JSON keys? +
Mainly for clean diffs. If two services serialise the same object with keys in a different order, a line-based diff or a git commit shows the whole file as changed even though the data is identical. Sorting both sides first makes the comparison meaningful. It also makes large config files far easier to scan, and produces deterministic output for caching or checksums.
Does it sort nested objects too? +
Yes, if you enable recursive sorting — every nested object is sorted at every level. You can also optionally sort array contents, though be careful: unlike object keys, array order IS meaningful in JSON, so sorting an array genuinely changes the data.
Should I sort arrays as well as keys? +
Usually not. Object key order carries no meaning, so sorting keys is always safe. Array order does carry meaning — [1, 2] is not [2, 1] — so sorting an array changes your data. Only sort arrays when they genuinely represent unordered sets, such as tags or permissions.