JSON Sorter

Sort JSON keys alphabetically, A→Z or Z→A, at every level or just the top — arrays always keep their order.

What It Does

This tool sorts the keys of every JSON object alphabetically, so two documents that differ only in key order become identical text. You can sort A→Z or Z→A, and every nested object or only the top level. Sorting uses natural number order, so item2 comes before item10. Arrays are never reordered, because the position of an element in a JSON array is part of its meaning.

When to Use It

  • Two API responses look different in a diff only because the server emitted keys in a different order.
  • You commit JSON fixtures or translation files to Git and want stable, reviewable diffs.
  • You are hunting for a key in a large object and want it in alphabetical order.
  • You are generating a canonical form of a document before hashing or signing it.

Worked Examples

{"zeta":1,"alpha":{"y":2,"b":3},"mid":[3,1,2]}

Keys sort at both levels; the array [3,1,2] keeps its order.

{"item10":"c","item2":"b","item1":"a"}

Natural order: item1, item2, item10 — not the item1, item10, item2 a plain string sort gives.

[{"b":1,"a":2},{"d":3,"c":4}]

A top-level array of records: each record's keys are sorted, the records stay in place.

Features

Runs as you type
Clear error messages with line and column
Explains what changed and why
One-click copy
Works offline
Nothing uploaded

How to Use

1. Paste your input into the top box. 2. Adjust the options if the page has any — the result updates as you type. 3. Read the notes under the result, then copy it.

Common Mistakes

  • Editing the result by hand and breaking the escaping. If you need to change the content, change the input and run it again — a single stray backslash makes the whole value invalid.
  • Assuming the browser preserved Windows line endings. A pasted CRLF becomes LF in any text box, so a byte-exact comparison with the original file can still differ.
  • Trusting that two documents are equal because they look equal. Key order, whitespace and number formatting differ between serializers; compare parsed values, not text.

Frequently Asked Questions

Everything runs in your browser. Your JSON is never uploaded, logged or stored.

Explore related topics

#JSON