CoreJSON

JSON Key Sorter

This tool sorts object keys in dictionary order when you format or minify JSON, recursively at every nesting level, producing stable output that is easier to compare and review. Sorting only rearranges how keys are written; array order, values and types are untouched. Combined with minifying it produces deterministic output, which is useful for config baselines, snapshot tests and diff reviews that should not be disturbed by key order. Computation runs in a Web Worker inside your browser and nothing is uploaded.

Open in the workbench Runs locally · nothing is uploaded

How to use it

  1. 1

    Paste or open your JSON

    Paste the JSON you want to sort into the input, or open a local file. The tool validates first, so invalid JSON fails fast instead of producing a half-finished result.

  2. 2

    Enable Sort keys

    Tick "Sort keys" in the toolbar, then choose an indentation (2 spaces / 4 spaces / Tab). Pair it with minify for single-line output.

  3. 3

    Run format or minify

    The Worker walks every object recursively and reorders keys in dictionary order. Arrays keep their order and nested objects are sorted at each level.

  4. 4

    Copy, download or compare

    Copy or download the result. Two JSON files with the same data can be sorted and then compared with the diff tool to remove key-order noise.

Key features

Recursive sorting everywhere

Not just the top level: objects inside arrays and objects nested within objects are all sorted by key name, so the whole document follows one style.

Key order only, data untouched

Array element positions, values, numeric precision and null are all preserved. Sorting drops no fields and performs no type inference.

Deterministic output

The same data produces byte-identical output after sort + minify regardless of the original order, ideal as a snapshot, cache key or audit baseline.

A perfect match for diffs

Sort both JSON files before a semantic or text comparison to eliminate the noise caused by reordered keys, leaving only the real changes visible.

Big integers and large files

Integers beyond 2^53-1 are detected with a lossless-mode hint; 10 MB files complete in the Worker so the main thread stays responsive.

No sign-in required

Open and use it — no registration and no ads.

Common errors & troubleshooting

  • ! In the JSON spec objects are unordered, so key order never affects how a program reads data. Sorting only changes the text form, benefiting readability and comparison, not semantics.
  • ! Arrays are not sorted — arrays are ordered, so reordering them would change meaning. To compare data while ignoring array order, use the corresponding option in the diff tool.
  • ! Keys are sorted by Unicode code point: for plain ASCII that is the familiar A–Z order; for CJK or mixed keys it follows code points, which may differ from phonetic ordering.
  • ! Numeric string keys such as "1", "10" and "2" sort as 1, 10, 2 (text order), not numeric order — this is expected for key sorting.

Frequently asked questions

Does sorting keys change my data?

No. Object keys are unordered in JSON semantics, so sorting only rearranges their written order; the key-to-value mapping, field count and types are all unchanged, and array order is preserved. Any parser reading the sorted JSON gets data equivalent to the original.

Are elements inside arrays sorted too?

No, and they should not be. Objects are unordered but arrays are ordered, so reordering elements would change what "the Nth item" means. This tool sorts object keys only; if you want to ignore array order when comparing two datasets, use the "ignore array order" option in the JSON diff tool.

What is the sorting rule, and how are CJK keys ordered?

Keys are compared by Unicode code point: plain ASCII and numeric keys follow the usual A–Z, 0–9 order (note it is text order, so "10" comes before "2"), while CJK and other characters are ordered by their code points, which may not match phonetic order.

Why sort JSON keys at all?

Mainly for stability and comparability. When the same data is emitted by different libraries or people, key order often differs, causing noisy text diffs, flaky snapshot tests and lower cache hit rates. Sorting makes output deterministic; with minifying it produces canonical JSON, a common step before code review, config baselining or signing.

Related tools