Sort JSON Online — Free, Private, Instant
Paste your JSON below and reorder its keys alphabetically — ascending or descending, recursively through nested objects. Runs entirely in your browser — your data never leaves your device.
JSON Sort
What does JSON key sorting do?
JSON sorting rewrites an object so its keys appear in alphabetical order — either ascending (A→Z) or descending (Z→A) — while leaving every value untouched. The tool walks the whole document recursively, so keys inside nested objects are sorted too. Arrays are left in their original order, since the sequence of array elements is often meaningful, but any objects found inside an array still get their keys sorted. For example:
{"c": 3, "a": 1, "b": {"z": 26, "y": 25}}sorted ascending becomes:
{
"a": 1,
"b": {
"y": 25,
"z": 26
},
"c": 3
}Because JSON objects are unordered by specification, this is a purely cosmetic transformation — the data means exactly the same thing before and after. What changes is how easy the document is for a human to scan.
When do you need to sort JSON keys?
- Diffing config or fixture files — two JSON files with the same content but different key order produce a noisy git diff. Sorting both files first makes the diff show only the actual changes.
- Comparing API responses— some backends don't guarantee stable key order between requests. Sorting both payloads before comparing makes it obvious whether the data actually changed.
- Normalizing exported data — data exported from different tools (databases, spreadsheets, CMSs) often orders keys differently. Sorting gives you one consistent shape across sources.
- Code review readability — a consistent, alphabetical key order makes it faster to find a specific field in a large config or translation file.
- Deterministic hashing or caching — if you hash a JSON string for a cache key or checksum, sorting keys first ensures logically identical objects always produce the same string.
How to sort JSON with JSON Shuttle
- Paste your JSON into the input box at the top of this page.
- Click “Ascending” or “Descending”. JSON Shuttle parses your input and rebuilds it with keys sorted A→Z or Z→A at every level of nesting.
- Copy or apply the result. Copy the sorted JSON from the output area, or click “Apply” to load it back into the input box for further edits.
If your JSON has syntax errors, sorting will show the same parse error you'd get from the validator. Use repair mode to auto-fix common issues like trailing commas or unquoted keys first.
Ascending vs. descending — which should I use?
- Ascending (A→Z)
- The conventional choice for readability, diffs, and documentation — most style guides and formatters (e.g. Python's
json.dumps(sort_keys=True)) default to ascending order. - Descending (Z→A)
- Useful when you want the opposite convention for a specific comparison, or simply want to eyeball a document from a different angle to spot inconsistencies.
- Key order and value types
- Sorting compares keys as plain strings (case-sensitive, code-point order), the same comparison JavaScript's
String.prototype.localeCompareuses. Numbers, booleans, strings, and null values are left exactly as they are — only their position in the object changes.
Frequently Asked Questions
- Is the JSON key sorter free?
- Yes. JSON Shuttle's sort tool is completely free with no signup, ads, or usage limits. It runs entirely in your browser.
- Does sorting send my JSON to a server?
- No. Sorting happens entirely client-side in JavaScript. Your JSON is never uploaded anywhere, which makes it safe to use on API responses, config files, or any data containing sensitive information.
- Does sorting reorder array elements too?
- No. Array order is often meaningful (a list of steps, a time series, a priority queue), so arrays keep their original element order. Only object keys are sorted — including the keys of any objects nested inside arrays.
- Will sorting change the meaning of my JSON?
- No. JSON objects are unordered by specification (RFC 8259) — any compliant parser treats {"a":1,"b":2} and {"b":2,"a":1} identically. Sorting only changes the order keys appear in the text, not the data itself.
- Can I undo a sort?
- Sorting shows the result in a separate panel first — your input is untouched until you click 'Apply'. If you already applied it and want the original back, use Ctrl+Z / Cmd+Z in the input box, or re-paste your original JSON.
Related JSON tools
- JSON Formatter — beautify or minify JSON
- JSON Validator — check if your JSON is well-formed
- JSON Repair — auto-fix common syntax errors
- JSON Escape / Unescape — escape strings for embedding inside other JSON
- About JSON Shuttle — privacy, use cases, full FAQ