{ }jsonkit
Format
Validate
Convert
Query
Generate

JSON sorter: sort keys alphabetically

Sort object keys A to Z or Z to A at every level, or canonicalize with RFC 8785.
Output
Order
219 B · paste or drop a file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
✓ complete219 B → 219 B0.0 ms

About JSON Sorter

This JSON sorter orders every object's keys alphabetically, through the whole document, and pretty-prints the result. Two documents with the same data but different key order come out identical after sorting.

Sort JSON before you diff, commit or deduplicate it. You can also reverse the order or sort arrays of plain values.

When you need exact bytes for hashing or signing, switch Output to RFC 8785. It writes canonical JSON with the JSON Canonicalization Scheme and shows its SHA-256 digest. Runs in your browser. Nothing is uploaded.

How it works

Recursive key sorting

Every object, at any depth, gets its keys written in sorted order. Values are untouched. Only the key order changes.

A→Z or Z→A

A→Z is the default. Switch to Z→A for reverse order. Keys compare by character code, so uppercase keys come before lowercase ones.

Sorting arrays

Arrays keep their order by default, because position often means something. Turn on Sort arrays to sort arrays of strings, numbers and booleans. Numbers sort by value. Arrays that contain objects or arrays always keep their order, since there is no single right way to rank objects.

Why sorted JSON diffs better

Text diffs compare line by line, so moved keys look like a wall of changes. Sort both sides first and the diff shows only real value changes.

Canonical JSON with RFC 8785

The RFC 8785 output removes all whitespace, sorts keys by UTF-16 code units and writes strings and numbers with ECMAScript serialization, which fixes exponent format and negative zero. Arrays keep their order. Duplicate keys and lone Unicode surrogates are rejected.

SHA-256 of the exact bytes

With SHA-256 digest on, the hash of the canonical text's UTF-8 bytes appears in the status bar below the panes. Copy and Download return only the canonical JSON.

Frequently asked questions

Does sorting JSON keys change the data?

No. The JSON spec gives object key order no meaning, and every value is kept. Any standard parser reads the sorted document as the same data.

How do I order JSON by key?

Paste the JSON and keep the order on A→Z. Every object's keys are sorted, including objects nested inside arrays. Keys compare by character code, so Zebra sorts before apple.

Are nested objects sorted too?

Yes. The sort is recursive, so objects inside arrays and objects nested many levels deep all get sorted keys.

Why aren't my arrays sorted?

Array order often matters (steps, rankings, coordinates), so arrays are kept as they are by default. Turn on Sort arrays to sort arrays of plain values. Arrays of objects always keep their order.

Is canonical JSON the same as sorting keys?

No. RFC 8785 also fixes whitespace, number format and string escaping. Those details change the bytes, so they matter for signatures and hashes. Use the RFC 8785 output for that, and the sorted output for reading and diffs.

Is my JSON uploaded to sort it?

No. Sorting runs in your browser.

When should I sort JSON keys?

Before diffing two documents, before committing config files, or when you need canonical output for hashing and caching. Consistent key order removes noise so real changes stand out.

Sources & last verified

We checked this tool's behavior and the claims on this page against the specifications below on . The tool runs in your browser, so the output you see is exactly what the engine produced.

Found a wrong result or an outdated claim? Report an error and we will check it again.