Sort JSON Keys

Sort keys in JSON objects recursively while preserving array order.

Input

Processed on your device

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.

  1. Paste JSON, choose Indentation and sort.
  2. Compare output values before adopting the result in a configuration or fixture.
  3. 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.

Find a tool