JSON Sorter
Paste JSON and sort all object keys alphabetically in one click. Choose ascending or descending order, deep or shallow sort, and optionally sort arrays.
Last updated: May 20, 2026
Find this tool useful? Support the project to keep it free!
Buy me a coffeeWhat is JSON Sorter?
Consistent key ordering in JSON makes files easier to read, compare, and diff in version control. When multiple developers edit JSON configuration files, API mock data, or translation files, unsorted keys create noisy diffs that hide real changes. Sorted JSON also makes it easier to find a specific key in a large object without scanning randomly.
This tool recursively sorts all keys in a JSON object (or array of objects) in alphabetical order. Deep mode sorts keys at every nesting level; shallow mode sorts only the top-level keys. You can sort descending instead of ascending, and optionally sort primitive values inside arrays.
How to Use JSON Sorter
Paste JSON into the input area or click "Load Sample"
Choose sort order: Ascending (A→Z) or Descending (Z→A)
Choose depth: Deep (all levels) or Shallow (top level only)
Optionally enable "Sort Arrays" to sort primitive array elements
Copy or download the sorted JSON output
Common Use Cases
- Developers normalising JSON config files before committing to version control to produce clean diffs.
- Teams sorting i18n translation JSON files so keys are consistently ordered across language files.
- API developers sorting JSON mock data files for readability and easier manual editing.
- QA engineers comparing two JSON responses by sorting both before a diff to isolate real differences from key-order noise.
- Data engineers sorting JSON schema files to maintain alphabetical property order across updates.
- Developers cleaning up auto-generated JSON (from ORM tools or code generators) for consistent key ordering.
Example Input and Output
A JSON config object with unsorted keys is sorted alphabetically so it reads predictably and diffs cleanly.
{
"timeout": 30,
"host": "localhost",
"debug": true,
"port": 8080,
"database": {
"pool": 10,
"name": "mydb",
"host": "db.example.com"
}
}{
"database": {
"host": "db.example.com",
"name": "mydb",
"pool": 10
},
"debug": true,
"host": "localhost",
"port": 8080,
"timeout": 30
}Privacy
All sorting runs in your browser. No data is uploaded to any server.
Key ordering in JavaScript
Modern JavaScript engines (V8, SpiderMonkey) preserve insertion order for string keys. JSON.stringify outputs keys in insertion order, so sorting the object before serialising guarantees a consistently ordered output.
Frequently Asked Questions
What is the difference between deep and shallow sort?
Deep sort recursively sorts keys at every nesting level — nested objects have their keys sorted too. Shallow sort only sorts the top-level keys and leaves nested objects in their original key order.
Does sorting change my JSON data?
No. Key order in a JSON object has no semantic meaning — only the key-value pairs matter. Sorting rearranges how the keys are written, but the data is identical.
What does "Sort Arrays" do?
Arrays have meaningful order by default (index 0 is first). "Sort Arrays" sorts array elements alphabetically when they are all strings or all numbers. Leave it off for ordered arrays like lists of steps or rows.
Why does sorted JSON produce cleaner git diffs?
If two developers each add a key to the same object at different positions, the diff shows both lines changed plus all lines between them shifted. With sorted keys, each new key is inserted at its correct alphabetical position, so diffs only show the added line.
Is my JSON sent to a server?
No. All sorting runs in your browser using JSON.parse and JSON.stringify. Your data never leaves your device.
What if my JSON is invalid?
The tool will show an error message with the parse error. Fix the JSON syntax first — you can use the JSON Formatter tool to identify and fix issues.
Related Tools
JSON Formatter
Format, validate, and beautify JSON instantly — with clear error messages, Tree View, Diff mode, and Schema validation.
JSON Tree Viewer
Visualize JSON data in an interactive tree structure.
JSON Path Tester
Test JSONPath expressions against your JSON.
JSON to TypeScript Interface
Convert any JSON object into TypeScript interfaces instantly — handles nested objects, arrays, union types, optional fields, and generics.
YAML to JSON Converter
Convert YAML to JSON and JSON to YAML — for config files, CI pipelines, and Kubernetes manifests.
XML to JSON Converter
Parse and convert XML to clean JSON instantly — attributes, namespaces, and nested elements handled.

