JSON Sort
Sort JSON object keys alphabetically
Input
Sorted Output
What Is JSON Sort?
JSON object keys have no defined order in the spec. Parsers and runtimes can return them in any order. Sorting keys alphabetically gives you consistent output for git diff, generating hashes, or reproducible output for testing. See RFC 8259 for the format.
This tool sorts the keys of your JSON objects recursively. Nested objects get their keys sorted too. Arrays stay in place; only object keys are reordered. Processing runs in your browser.
How to Use This Tool
Paste Your JSON
Paste JSON into the left editor or upload a file. Use Sample for example data. The tool accepts any valid JSON.
View Sorted Output
The right panel shows the same JSON with keys sorted alphabetically. Nested objects are sorted recursively. Invalid JSON will show an error.
Copy or Download
Use Copy or Download to get the result. For formatting without sorting, use the JSON Formatter. For minifying, use the JSON Minifier.
JSON Sort Examples
Here is an example of sorting JSON object keys alphabetically. Nested objects are sorted recursively.
Example: Subscriber record with unsorted keys
Input (keys in arbitrary order):
Sorted output:
When Key Order Matters
Git diffs are cleaner when keys are sorted: changes stand out instead of being buried in reordered lines. Some systems use JSON stringification for hashing or signing; sorted keys make the output deterministic. In JavaScript, JSON.stringify does not guarantee key order. This tool gives you consistent output regardless of input order.
Frequently Asked Questions
Are array elements sorted?
No. Only object keys are sorted. Array order is preserved. Sorting array elements would change the data; this tool only reorders keys within objects.
Is the sort case-sensitive?
Typically yes. Keys are sorted alphabetically, so "planId" and "PlanId" would be in different positions. Check the output to confirm the tool's behavior.
Is my data sent anywhere?
No. Sorting runs in your browser.
Does this change the data?
No. Only the order of keys changes. Values and structure stay the same. The result is semantically identical JSON.
Can I sort by a custom order?
This tool sorts alphabetically by default. For custom ordering, you'd need to process the JSON in code or use a different tool.
Related Tools
For JSON syntax, see RFC 8259 and MDN. The JSON specification at json.org defines the format. For command-line JSON processing, jq supports sorting and more.