Data Tools
JSON Sorter: Sort Keys Alphabetically
Sort JSON object keys A to Z, Z to A or in natural order at every level, optionally sort array items too, and copy the result pretty-printed or minified.
How to use JSON Sorter: Sort Keys Alphabetically
Paste JSON and the sorted version appears as you type. Choose the order and indent, untick Sort nested objects too to sort only the top level, and tick Also sort array items if array order does not matter. Then press Copy result.
- Paste your JSONPaste an object or array into JSON data. Syntax errors are reported with the line, column and a likely cause.
- Choose order and indentPick A → Z by character code, case-insensitive A → Z or Z → A, and 2 spaces, 4 spaces, Tab or Minified.
- Copy the sorted JSONDecide whether nested objects and arrays are sorted, check the note, then press Copy result.
Sort orders with examples
Sorting {"b":2,"a":{"d":4,"c":3}} gives {"a":{"c":3,"d":4},"b":2}; objects nested inside other objects or arrays are sorted too unless you untick Sort nested objects too. A → Z (character code) compares raw character codes, so digits come before capital letters and capitals before lower case: keys 10, 2, Name, age, item10 and item2 come out in exactly that order. A → Z (case-insensitive, numbers by value) ignores case and reads runs of digits as numbers, giving 2, 10, age, item2, item10, Name. Z → A reverses the character-code order. The note under the result counts the objects and keys that were sorted.
Arrays, big numbers and why sorted keys help
Array items keep their order by default, since order often carries meaning, but objects inside arrays still have their keys sorted. Tick Also sort array items to order the values as well: null and booleans first, then numbers by size, then strings, arrays and objects, so [3,"b",1,null,true,"a"] becomes [null,true,1,3,"a","b"]. Sorted keys make diffs and code reviews cleaner, because two files holding the same data then serialise identically. In recent browsers, integers longer than 15 or 16 digits and long decimals are kept exactly as written; older browsers may round them, and a note says so.
Accuracy and data handling
Keep the original data and spot-check fields, types and delimiters before using an important conversion. The calculation runs in your current browser; the tool code does not send the input to a processing API.
FAQ
Why sort JSON keys?
JSON objects have no guaranteed key order, so different programs may write the same data in different orders. Sorting the keys first means a text diff shows only the values that really changed.
Are array elements sorted too?
Not by default: arrays keep their original order, although objects inside them have their keys sorted. Tick Also sort array items to sort the values themselves.
What if my JSON has an error?
The error shows the line and column, plus a tip for common causes such as single quotes, a trailing comma, comments or unquoted keys. The result updates as soon as the JSON is valid.
Can I minify while sorting?
Yes. Set Indent to Minified (one line) to get sorted JSON on a single line, or choose 2 spaces, 4 spaces or Tab for readable output.
More Data Tools
Related toolsDeep merge JSON documents, apply a Merge Patch and see which values changed.
Compare two JSON documents and list every added, removed or changed value.
Remove duplicates from a list or JSON array and see how often each value repeats.
Turn CSV into a JSON array or JSON Lines with optional type detection
Turn JSON arrays, objects or JSON Lines into CSV you can preview and download
Trim spaces and remove blank rows, empty columns and duplicates from CSV.