JSON Sort
Sort JSON object keys alphabetically
Input
Sorted Output
Paste your input on the left and the result shows up here.
Or drop a file on this box, , or .
What is JSON Sort?
Ever opened a JSON file and thought "why are these keys in such a random order?" This tool fixes that. It sorts all your JSON (JavaScript Object Notation) object keys alphabetically, making everything way easier to read and compare.
Key order doesn't change what a JSON object means (the RFC 8259 JSON specification calls objects unordered), but sorted keys make files much easier to scan and diff. This tool reorders keys and leaves every value alone, including big integers like 8901240544102066246, which keep every digit. If you want to know how JavaScript itself orders keys, MDN's Object.keys page explains it.
The order is plain character-code order, the same one Array.prototype.sort() gives strings, so Roaming lands before apn because capitals come first. Keys that look like whole numbers, such as "2" and "10", are the exception: a JavaScript object always lists those first, smallest number first, whichever direction you pick. Parsing and sorting both happen on the JSON text inside this tab.
How to Use JSON Sort
Paste, choose a direction, take the result. The output re-sorts about 300 ms after your last keystroke; you will not find a Sort button.
Paste JSON or Upload File
Paste JSON on the left, or Upload a saved .json or .txt export. Sample loads three subscriber records whose keys (subscriberId, plan, dataUsage, status) are not in alphabetical order. A smaller one to try by hand:
{"carrier": "Verizon", "subscriberId": "SUB-1001", "plan": "5G"} Output becomes {"carrier": "Verizon", "plan": "5G", "subscriberId": "SUB-1001"} – keys sorted A–Z. Valid per RFC 8259.
View Sorted Output
The right Sorted Output panel shows the result automatically. Keys are sorted at every level; nested objects are sorted recursively. Click A to Z to flip to Z to A and back. Values stay unchanged; only key order changes. Great for cleaner Git diffs and easier comparison.
Copy or Download
Copy sends the sorted JSON to the clipboard; Download writes sorted.json, ready to commit so the next diff shows real edits and not shuffled keys. The output panel is read-only, so make any fixes in the input.
When You'd Actually Use This
Version Control
Sort JSON keys before committing to Git. Diffs get cleaner and easier to review, with less noise from keys that just moved around.
Comparison
Sort JSON objects before comparing them. When keys are in the same order, differences are easier to spot.
Config Files
Organize configuration files for better readability. Sorted keys make it easier to find and edit specific settings.
Easier Navigation
Find properties faster in large JSON objects. Alphabetical order makes it easier to locate specific keys.
Common Questions
Is my JSON data stored?
No. Sorting happens entirely in your browser using JavaScript. Your data never leaves your computer.
Does sorting change what the JSON means?
No. JSON object key order doesn't carry meaning, so sorted JSON parses to the same data as unsorted JSON. The exception is code that (wrongly) relies on key order, like a test comparing raw strings. That's usually exactly the thing sorting helps you catch.
What about arrays?
Arrays are not sorted – only object keys are sorted. Array element order is preserved. If you have an array of objects, each object's keys are sorted.
How are keys ordered exactly?
By plain character code, so uppercase sorts before lowercase (Zone comes before apple) and it isn't locale-aware. One JavaScript quirk to know: keys that look like non-negative integers ("2", "10") always come first, in numeric order, because that's how JavaScript objects store them. Nested objects are sorted the same way at every level.
What if my JSON is an array?
If your JSON is an array of objects, each object's keys will be sorted. The array order itself is preserved. An array of objects also reads well as a table: the JSON parser on our home page gives each object a row and each key a column.
Does it work with invalid JSON?
No. The input JSON must be valid. If it's invalid, you'll see an error. Use the JSON Validator to find the problem or the JSON Fixer to repair it first.
Other JSON Tools You Might Need
Sorted keys pay off when two documents are compared or reviewed side by side. These are the pages a sorted file usually goes to next: