How to use Sort JSON Keys
Reorder object keys for predictable diffs and easier inspection. Nested objects are sorted while list positions remain in their original order.
- Paste JSON, choose Indentation and sort.
- Compare output values before adopting the result in a configuration or fixture.
- Select Sort JSON Keys and review the result.
Example input
{"title":"Field Notes","inStock":true,"quantity":12,"tags":["paper","stationery"]}Example use
Get two independently generated objects into a consistent order before reading a line diff.
Output and compatibility
Sorting parses and reserializes values. Numeric-looking keys can follow JavaScript enumeration rules; very large numeric literals or duplicate keys can change under parsing.
Troubleshooting
If exact numeric literals matter, preserve those values as strings beforehand or use JSON Formatter and keep the existing key order.
Use JSON Diff to compare objects without changing their order.
Frequently asked questions
Does it sort array elements?
It sorts keys in objects, including objects inside arrays. Array item order remains.
Can it preserve duplicate keys?
Normal JSON parsing resolves duplicate keys before sorting.