JSON Sort Keys
Sort every object key recursively for stable, deterministic JSON.
- Runs locally in your browser
- No upload required
Try it
Supported formats
Privacy
Runs entirely in your browser. Your input is never uploaded, stored, or sent to a third party.
Sorted every object key in 25 characters of JSON.
How it works
- Scanned the JSON into a syntax tree without converting number literals.
- Sorted each object's members by key using code-unit ascending order.
- Re-emitted the tree with the chosen indentation; array order was preserved.
- Sorting is locale-independent, so the result is stable across machines.
Methodology
- Tokenize the document with the F054 verbatim JSON scanner.
- Recursively sort each object's members by key; copy arrays unchanged.
- Re-emit the tree with the chosen indentation.
Usage
- Paste or type a JSON document.
- Choose 2 spaces, 4 spaces or a tab.
- Run the tool and copy the key-sorted JSON.
Examples
These are examples, not current values: they use fixed inputs, while the interactive tool computes live results in your browser.
Nested objects
{
"text": "{\"b\":1,\"a\":{\"d\":4,\"c\":3}}",
"indent": "2"
}Array order preserved
{
"text": "{\"z\":[3,1,2],\"a\":true}",
"indent": "2"
}Big integer preserved
{
"text": "{\"id\":123456789012345678901234567890,\"a\":1}",
"indent": "2"
}Limitations
Why sort keys
Two semantically equal documents can differ only in key order. Sorting keys makes diffs, hashes and reviewing stable and reproducible.
Frequently asked questions
- Is the sort locale-aware?
- No. Code-unit ascending order is used so the result is identical on every machine and in diffs.
- Does it sort array values?
- No. Only object keys are sorted; array order is data and is preserved.
- Is my data uploaded?
- No. The sort runs entirely in your browser and is never sent anywhere.
Sources
Send feedback
Tell us if this tool helped, report a problem, or suggest a tool. Only the message you type is sent — never the input you used in the tool.
Was this tool useful?
Prefer to write to us directly? See the contact page.