convert

Sort JSON Keys

Sort JSON object keys alphabetically (recursively) for clean diffs and stable output.

Runs on your deviceBatch readyPaste textNew

Paste or drop

Paste text below, or drop a file instead.

0 chars · 0 lines
…or drop a file
Drag and drop, or choose files
JSONTXT

Choose an output

Sort JSON object keys alphabetically (recursively) for clean diffs and stable output.

Fine-tune

Optional — sensible defaults are already set.

Indent

About Sort JSON Keys

This tool reorders object keys alphabetically, either at every level or only at the top, in ascending or descending order. Arrays keep their element order, since that order is meaningful. Sorted keys give you stable output that diffs cleanly between versions.

When it helps

  • Normalizing two JSON files before comparing them, so a diff shows real changes instead of reordered keys.
  • Keeping translation files, feature-flag configs or package.json sections in a predictable order.
  • Producing deterministic output for snapshot tests or for hashing a JSON document.

Tips

  • Turn off "Sort nested objects too" if only the top-level keys should be ordered and inner structures left as written.
  • Sorting uses locale-aware comparison, so uppercase and lowercase versions of a letter sort near each other rather than all capitals first.
  • Choose the indent (2 spaces, 4 spaces or tab) to match your project's formatting so the sorted file does not create whitespace noise in git.

Good to know

Quick answers about sort json keys in your browser.

Not according to the JSON specification, which treats objects as unordered. Some code does depend on order in practice, so check before sorting files that are read by order-sensitive tools.

No. Array elements stay in their original order. With nested sorting on, objects inside arrays have their own keys sorted, but the array itself is not reordered.

Yes. There is no sign-up, no watermark and no limit on how many files you process.

No. Files are read and processed locally in your browser, so they never leave your device.

Related tools