JSON Key Sorter
Alphabetise the keys of any JSON document at every level of nesting, then pretty-print the result.
Keys are sorted live as you type. Nothing leaves your browser.
Options
Order
Letter case
Indentation
Lists
Off keeps array order. On sorts arrays whose items are all simple values.
Sorted JSON
How to sort JSON keys alphabetically online
Paste your JSON
Drop a JSON document into the input and its keys are parsed and sorted live on every keystroke.
Choose the order and case
Switch between A to Z and Z to A, and decide whether letter case is significant or ignored.
Set indentation and lists
Pick 2 spaces, 4 spaces, or tabs, and optionally sort arrays that hold only simple values.
Copy the result
The sorted, pretty-printed JSON appears with a valid confirmation, and Copy takes it to your clipboard.
Why use this tool
Recursive key sorting
Every object is reordered, from the top level down through nested objects and objects held inside arrays, in a single pass.
Array order stays put
Element order in arrays is preserved by default so ordered data is never scrambled. Turn on list sorting only when you want simple lists ordered too.
Direction, case, and indentation
Sort A to Z or Z to A, group letters regardless of case or respect it, and format with 2 spaces, 4 spaces, or tabs.
Precise parse errors
Invalid input shows the parser message with the line and column where it failed, plus a pointer to the exact spot on that line.
Types preserved exactly
Strings, numbers, booleans, and null keep their original types and values. Only the order of keys changes.
Runs entirely in your browser
Everything happens on your device. Nothing you paste is uploaded or stored.
About this tool
JSON Key Sorter parses your document and rewrites every object with its keys in alphabetical order, all the way down through nested objects and objects held inside arrays. The output is pretty-printed with the indentation you choose, so two files that hold the same data but list their keys in a different order become directly comparable line by line.
Sorting keys makes diffs smaller and reviews faster. Configuration files, API fixtures, and translation catalogs stop producing noisy changes just because someone added a field in the middle. Array element order is left untouched by default, because the position of items in a list is usually meaningful, and a separate option sorts lists made only of simple values when you do want them ordered. You can sort ascending or descending, treat letter case as significant or ignore it, and indent with 2 spaces, 4 spaces, or tabs.
Invalid input is reported with the exact line and column where parsing stopped, so a stray comma or an unclosed brace is easy to find. Once the keys are in order you can hand the result to the JSON formatter to explore it as a collapsible tree, shrink it with the JSON minifier, or turn it into a config with JSON to YAML.
Frequently asked questions
- How does key sorting work?
- Paste JSON and it is parsed, then every object is rebuilt with its keys in alphabetical order, from the top level down through nested objects and objects inside arrays. The result is pretty-printed and updates live as you type or change options.
- Does it change the order of arrays?
- No, not by default. The position of elements in an array is often meaningful, so array order is preserved. If you turn on list sorting, arrays whose items are all simple values such as strings, numbers, booleans, or null are ordered too, while arrays containing objects are always left as they are.
- Can I sort in reverse or ignore letter case?
- Yes. Choose A to Z or Z to A, and decide whether letter case matters. Ignoring case groups names like Name and name together, while case-sensitive order sorts strictly by character, which matches the output of common command-line JSON tools.
- What happens if my JSON is invalid?
- The tool shows the parser error along with the line and column where parsing failed and a pointer to the offending spot, so you can fix a misplaced comma or quote quickly. Your text stays in the box while you correct it.
- Is my data uploaded anywhere?
- No. Everything runs in your browser; nothing is sent to a server.
- Does it handle large files?
- Yes. Sorting runs on your device and the output area scrolls rather than stretching the page. Very large documents depend on your available memory since everything is processed in the browser tab.
Related tools
JSON Formatter & Validator
Pretty-print, minify, or explore JSON as a collapsible tree, with syntax errors shown inline.
JSON Minifier
Minify JSON to the smallest single line, with original vs minified byte size and the percentage saved.
JSON to YAML
Convert JSON to YAML and YAML back to JSON, in both directions, with your choice of indentation.
API Key Generator
Generate cryptographically random API keys and tokens in hex, base62, or base64url, with control over length, an optional prefix, and bulk output.
ASCII Table Reference
The full ASCII character set with decimal, hex, octal, binary, and HTML codes. Search by code, character, or name.
Atbash Cipher
Mirror the alphabet so A swaps with Z, B with Y, and so on. Atbash is its own inverse, so one field both encodes and decodes as you type.