Skip to content
TextArray
100% local

Sort JSON

Sort the keys of a JSON object alphabetically, recursively and consistently.

Input
Output

Sort JSON

Paste any JSON and this tool re-emits it with every object's keys in alphabetical order, all the way down. Nested objects are sorted recursively, so two files that differ only in key order become identical byte for byte — which is exactly what you want before diffing config files, comparing API responses or committing generated JSON that would otherwise churn on every save.

The key order is case-insensitive with a deterministic tiebreak, so "Name" and "name" sit together and the same input always produces the same output. Choose A to Z or Z to A, and pick the indentation that fits your workflow: two spaces, four spaces, a tab, or fully minified on one line. Numbers, booleans, null and string values keep their original form — sorting only rearranges object keys, it never rewrites your data.

By default arrays are left exactly as they are, because the order of items in an array usually carries meaning. Turn on "Sort primitive arrays" and arrays made purely of numbers are sorted numerically and arrays made purely of strings are sorted alphabetically. Arrays that mix types, or that contain objects, are deliberately left untouched so their meaning is never silently changed. If the same key appears twice in an object, JSON keeps the last value, following the standard parser.

The live tally shows how many keys were sorted, how deep the structure nests and the size of the output. Everything runs entirely in your browser, so even private payloads and secrets stay on your machine — nothing is ever uploaded.

FAQ

How are keys ordered exactly?
Alphabetically and case-insensitively, with a deterministic tiebreak so "Name" and "name" stay adjacent and the output is always the same for the same input. Sorting is recursive through every nested object.
Does it sort arrays too?
Not by default, because array order usually matters. Turn on "Sort primitive arrays" to sort arrays of only numbers numerically and arrays of only strings alphabetically. Mixed or object arrays are left as they are.
What happens to duplicate keys?
JSON does not allow two values for one key, so the standard parser keeps the last one. If your input has {"a":1,"a":2}, the result contains only "a": 2.
What if my JSON is invalid?
The tool shows a calm error telling you to check for missing quotes or commas, and where the parse failed when the browser reports a position. Fix the input and the sorted result appears as you type.
Is my JSON uploaded anywhere?
No. Parsing and sorting happen entirely in your browser, so even private data and secrets never leave your device.