Your JSON never leaves your browser; nothing you paste is uploaded. The two Send buttons pass the result between pages inside your browser tab only.
JSON Sorter
Sort JSON keys and arrays in your browser. Your JSON never leaves your browser, and nothing you paste is uploaded.
A JSON sorter puts the keys of a JSON document in a predictable order. That matters more often than you would think: a sorted config file gives stable diffs and cleaner code review, a canonical key order makes JSON safe to hash or compare, a sorted API response is easier to read, and sorted test fixtures stop spurious failures. Use this JSON sorter online, free with no upload: your JSON never leaves your browser.
How do I sort JSON keys alphabetically?
Paste your JSON, or upload a file, and leave Sort object keys on Ascending. The sorted result appears on the right as soon as you stop typing, with every object ordered at every depth. Copy it, download it as sorted.json, or send it to the formatter. Nothing is uploaded.
That covers the common request to sort JSON alphabetically. The default compares keys by UTF-16 code unit, the same rule most tools use, so capital letters come before lowercase ones. If you would rather sort JSON keys online without that quirk, switch Case to Ignore case, or choose Natural order so item2 comes before item10. Descending reverses the result, and Top level only leaves nested objects alone.
How to use this JSON sorter
- Add your JSON by pasting it, choosing a file or dropping one on the upload box. Load sample JSON inserts an example.
- Pick the options: key order, case, plain or natural ordering, depth, array sorting, duplicate keys and indent. Changes apply live; press Sort to run it yourself.
- Copy, Download as .json, Send to JSON Formatter, or Validate against a schema. Results over about 2 MB show a preview, but all four buttons use the whole result.
- Limits: live updates pause above about 1 MB, so press Sort. Up to 200 levels of nesting are accepted, and input above 50 MB is refused with a message.
Once the keys are in order, format and validate the sorted text on the homepage, or diff two versions side by side to see only the real changes. A schema check confirms the shape, and a JSONPath query pulls out the part you care about. The guides on comparing JSON files and formatting JSON cleanly explain the surrounding workflow.
Does sorting JSON keys change its meaning?
No. The JSON specification defines an object as an unordered collection of name and value pairs, so reordering keys does not change the data any parser sees. Arrays are different, because their order is part of the value. That is why this tool leaves arrays alone unless you ask otherwise.
Some programs do treat key order as meaningful, for example hand-written configuration, signed payloads or tools that diff text. Sorting is safe for parsers and visible to everything that reads the raw text, so sort deliberately.
How do I sort a JSON array by a property?
Tick Sort arrays and type a property path such as address.city. Items are ordered by that value: null, booleans, numbers, strings, arrays and objects, in that fixed order. An item without the property goes last. Pick Ascending or Descending, and leave the path empty to sort arrays of plain values.
To sort JSON array by key, type that key as the path; dotted paths reach into nested objects. Items keep their original order when their values tie.
Why does JSON key order matter for diffs?
A text diff compares lines, not meaning. Two files with the same data but different key order show many changed lines, and a real change hides among them. Sorting both files the same way first makes the diff show only what actually changed, which also helps hashing and caching.
Run the same options on both versions, then compare them. Because this JSON key sorter keeps number text and string content exactly, only the order changes.
Worked example: sort keys, then sort an array by a property
Both results below were produced by this tool. The first object is sorted with the default options (Sorted 9 keys in 2 objects).
Input
{
"zeta": 1,
"Alpha": {
"city": "Oslo",
"Zip": "0150",
"country": "NO"
},
"beta": [
3,
1,
2
],
"id": 12345678901234567890,
"price": 1.0,
"active": true
}
Output (Ascending, case-sensitive, all levels)
{
"Alpha": {
"Zip": "0150",
"city": "Oslo",
"country": "NO"
},
"active": true,
"beta": [
3,
1,
2
],
"id": 12345678901234567890,
"price": 1.0,
"zeta": 1
}
The second example leaves key order alone and sorts the array by address.city (Arrays sorted: 1). The item with an empty address has no city, so it goes last.
Input
[
{
"name": "Zoe",
"address": {
"city": "Oslo"
}
},
{
"name": "Adam",
"address": {
"city": "Bergen"
}
},
{
"name": "mia",
"address": {}
},
{
"name": "Eli",
"address": {
"city": "Aalborg"
}
}
]
Output (Sort arrays on, path address.city)
[
{
"name": "Eli",
"address": {
"city": "Aalborg"
}
},
{
"name": "Adam",
"address": {
"city": "Bergen"
}
},
{
"name": "Zoe",
"address": {
"city": "Oslo"
}
},
{
"name": "mia",
"address": {}
}
]
JSON sorting gotchas
Each result below comes from running the tool.
1. Key order is not meaning, but it still matters
Parsers ignore key order, yet diffs, hashes and humans do not. Treat sorting as normalisation: do it the same way every time, and only where order carries no meaning.
2. Integer-like keys keep their own order
JavaScript moves integer-like keys to the front of an object. Parsing and printing {"b":1,"2":2,"a":3,"1":4} with JSON.parse gives {"1":4,"2":2,"b":1,"a":3}. This tool keeps entries as written, so unsorted output is {"b":1,"2":2,"a":3,"1":4} and sorted output is {"1":4,"2":2,"a":3,"b":1}.
3. Case-sensitive, ignore case and natural order differ
For the keys b, B, a, A, item10, item2, 10 and 2: plain order gives 10, 2, A, B, a, b, item10, item2. Ignore case gives 10, 2, A, a, B, b, item10, item2. Natural order gives 2, 10, a, A, b, B, item2, item10, and natural with ignore case gives 2, 10, A, a, B, b, item2, item10. Note how "10" and "2" swap places, and "B" moves behind "a".
4. Arrays are ordered, so they are not sorted by default
Sorting keys of {"steps":["test","build","deploy"]} leaves {"steps":["test","build","deploy"]}. Only with Sort arrays on does it become {"steps":["build","deploy","test"]}, which changes the order of the steps and could change what the data means.
5. Large integers and number text survive
Parsing {"id":12345678901234567890,"price":1.0,"small":1e5} with JSON.parse and printing it again gives {"id":12345678901234567000,"price":1,"small":100000}, losing digits and the trailing zero. This tool prints {"id":12345678901234567890,"price":1.0,"small":1e5}, because it keeps number text exactly as written.
6. Duplicate keys
For {"a":1,"a":2} the tool reports: Duplicate key "a" at line 1, column 8. With Keep last duplicate ticked the result is {"a":2}, the same value JSON.parse would keep.
Frequently Asked Questions
What is a JSON sorter?
A JSON sorter reorders the keys inside JSON objects, and optionally the items in arrays, so the same data always appears in the same order. It does not change values. This one runs in your browser, keeps number text exactly as written, and lets you choose the sort rules.
Does sorting JSON keys change its meaning?
No. A JSON object is an unordered set of key and value pairs, so sorting its keys leaves the data identical to any parser. Arrays are different: their order is part of the data, so this tool never reorders an array unless you switch Sort arrays on.
How do I sort a JSON array by a property?
Tick Sort arrays, then type a property path such as address.city in the path box. Items are ordered by that value: null, booleans, numbers, strings, arrays, then objects, with items that lack the property placed last. Choose Ascending or Descending for the order.
How are duplicate keys handled?
By default the tool stops with an error that names the duplicate key and its line, because most parsers silently keep only one value. Tick Keep last duplicate to let the last value win, which is what JSON.parse in JavaScript does.
Is my data uploaded anywhere?
No. Parsing, sorting and writing all run as JavaScript in your browser, so your JSON never leaves your browser. The Send buttons pass the result to another page on this site inside your browser tab only.
Built and maintained by Deepak Kumar, a developer who wanted a JSON tool that respects your privacy. Your JSON never leaves your browser.