JSON Sorter

Alphabetize JSON object keys at every nesting level. Produce deterministic, hash-stable output. Built for version control diffs.

ORDER
INPUTunsorted JSON
SORTED OUTPUT
// sorted JSON appears here

Why sorted keys matter

Object key order is undefined in the JSON spec. Most parsers preserve insertion order, but the producer's insertion order depends on language, library version, hash seed, and other things that are not under your control. Two programs that generate the same data can produce different files.

That breaks anything downstream that compares bytes: file hashes for cache invalidation, version-control diffs, signature schemes that sign the canonical JSON. Sort the keys once and the same data always produces the same bytes — your diff tool stops showing imaginary changes.

Recursive at every depth

The sort walks the whole tree. Nested objects get the same alphabetic ordering, so the entire document becomes canonical, not just the top level.

Privacy first

Sorting happens in this browser tab. Lockfiles, manifests, signed payloads — paste anything and it never leaves your machine.

Common questions

Why sort JSON keys?
Three main reasons: stable diffs in version control (the same data always produces the same output), reproducible file hashes for cache invalidation, and easier visual scanning of large objects. Sorted keys are how npm writes package-lock.json, how Bun writes bun.lock, and how most build tools serialize manifests.
What does this do to arrays?
By default, nothing — arrays in JSON are ordered by definition, and reordering them changes meaning. Enable "sort arrays" only when the order is meaningless (a set of tags, a list of features) and you want canonical output. Mixed arrays are sorted by their JSON representation lexicographically.
Are keys sorted at every level?
Yes. The sort is recursive — every object at every depth gets the same treatment. A nested {"z": {"b": 1, "a": 2}} becomes {"z": {"a": 2, "b": 1}}.
What sort order is used?
JavaScript's default string sort, which is essentially Unicode code-point order. Uppercase letters come before lowercase, digits before letters, ASCII before non-ASCII. For human-readable case-insensitive sort, lowercase the keys first or normalise before sorting.
Does sorting break my schema?
No. JSON object keys have no defined order in the spec — every parser builds the same in-memory representation regardless of input order. Sort the file, re-run your tests, you will see no behavior change.
Is my data private?
Yes. Sorting runs locally in this browser tab. Nothing is uploaded or logged.