Tool Kumar tool
Sort JSON keys
Paste JSON to see the keys of every object in alphabetical order, nested objects included. Arrays keep their order, so the data means the same thing; only the order of the keys changes.
How to use this tool
- Paste your JSON or open a file.
- Read the sorted output in the Format view. Sort keys is switched on in the More options menu.
- Copy or download the result, or choose Use as input (Ctrl+Enter) to sort the input itself. Ctrl+Z undoes it.
Worked example
Every object is sorted, including the nested ones. The owners list keeps its order, and "10" sorts before "2" because keys are compared as text.
Input
{"version":2,"name":"tool-kumar","10":"ten","2":"two","scripts":{"test":"node --test","build":"next build","dev":"next dev"},"owners":[{"role":"admin","email":"ada@example.com"},{"role":"editor","email":"lin@example.com"}]}Output
{
"10": "ten",
"2": "two",
"name": "tool-kumar",
"owners": [
{
"email": "ada@example.com",
"role": "admin"
},
{
"email": "lin@example.com",
"role": "editor"
}
],
"scripts": {
"build": "next build",
"dev": "next dev",
"test": "node --test"
},
"version": 2
}Options and edge cases
- Sorting is recursive: objects inside objects and inside arrays are sorted too.
- Arrays keep their element order. Sorting array values, or records by a property, is a different operation.
- Keys are compared as text, character by character, so "10" comes before "2" and uppercase letters come before lowercase ones.
- Values do not change, and numbers keep their source digits.
- To confirm that only key order changed, compare both versions in JSON diff with Ignore key order turned on.
Private by default
Your document stays in this browser. Tool Kumar parses, converts and creates downloads on your device, with no account or upload step.
Sort JSON keys questions
- How do I sort JSON keys?
- Paste the JSON here. The output lists the keys of every object alphabetically, at every depth. Copy it, or apply it to the input with Use as input.
- How do I sort a JSON file alphabetically?
- Open the file with Open file (Ctrl+O, or ⌘O on a Mac), then download the sorted output. Only object keys move; arrays keep their order.
- Does sorting change my data?
- No values change. JSON objects are unordered, so standard parsers read the same data. Code that relies on key order may still behave differently.