My Tools Garage

JSON Sort Keys

Alphabetise JSON object keys, deeply and instantly.

in-browser

How to use

  1. 1 Paste your JSON into the input box.
  2. 2 Choose ascending or descending key order.
  3. 3 Set the indentation you want for the output.
  4. 4 Copy the sorted JSON from the output panel.

About JSON Sort Keys

JSON Sort Keys reorders the keys of a JSON object into a predictable alphabetical sequence, recursively, so two files that hold the same data always look the same.

Inconsistent key order is a common source of noisy diffs, hard-to-read config files and flaky snapshot tests; normalising the order makes objects easy to scan and makes version-control changes reflect real edits rather than incidental reshuffling.

Paste your JSON and the tool parses it, walks every nested object and sorts each one’s keys, then re-serialises the result with the indentation you choose.

Arrays are left in their original order because position is meaningful in a list, but any objects inside those arrays are sorted too.

You can switch between ascending (A→Z) and descending (Z→A) order, and pick how many spaces to indent so the output matches your project’s formatting.

Everything runs locally in your browser, so even sensitive payloads never leave your machine, and the tool keeps working offline once loaded.

If the input is not valid JSON you get a clear error pointing at the problem instead of a silent failure.

It is a quick way to canonicalise API responses, tidy configuration files or stabilise fixtures before committing them.

FAQ

Does it reorder array elements?

No. Array order is preserved because position matters in a list. Only the keys of objects, including objects nested inside arrays, are sorted.

What happens with invalid JSON?

The tool shows a clear parse error describing what went wrong, and produces no output until the input is valid JSON.