JSON Sorter & Deduper

Sort object keys recursively, sort arrays alphabetically or numerically and dedupe items — then pretty-print the result with stats. Runs in your browser.

Input JSON

Options

How it works

About JSON Sorter & Deduper

Unsorted JSON is hard to eyeball: equivalent documents differ, review diffs grow noisy, and duplicate entries inflate payloads. A deterministic sort turns a hand-edited blob into a canonical form you can diff, cache, or commit with confidence.

Use it to normalize config files before committing, to shrink response payloads by removing duplicate items, or to prepare stable fixtures for tests and examples. Sorting and deduplication happen locally, so private schemas and payloads never leave your browser.

Key ordering is locale-aware, not bytewise

Object keys are sorted with `localeCompare`, which follows locale collation rules rather than code-point order. That is the right choice for readability — `Zebra` lands after `apple`, and underscore-prefixed keys group together — but it means the output is not a byte-stable canonical form. The same input can produce different key order on a machine with a different locale or ICU version, which defeats the exact case of normalising a file so diffs collapse.

Numeric mode applies to array values, not keys: a field holding `"10"` and `"2"` sorts as 2 then 10, because both sides are coerced with the unary plus before comparison. It engages only when both values parse as finite numbers, so a mixed array falls back to string comparison. Key sorting is always alphabetical, with no numeric variant offered.

How arrays are ordered and deduplicated

Array elements are compared by value, and an object element is reduced to the string form of its first property before comparison — so an array of records sorts by whatever happens to be the first key, which is fragile when the key set varies between records. Two numbers are compared by subtraction; everything else goes through `localeCompare` on its string form. Descending simply negates the comparator result.

Deduplication is a separate pass that runs after sorting and keeps the first occurrence of each distinct item. Primitives are keyed by `typeof` plus value, so `1` and `"1"` survive as separate entries. Objects are keyed by `JSON.stringify`, which means two records with identical content in different key order are treated as distinct and both kept — sort keys first if you want order-insensitive dedupe.

Practical limits

Dedupe is force-disabled whenever array sorting is set to None, and the checkbox is disabled in that state to make the dependency visible. The two settings interact in a way that surprises people: enabling dedupe while sorting is off silently does nothing.

Sorting also rebuilds the tree, so whatever the JSON parser could not represent is already gone beforehand — duplicate keys collapse to the last occurrence, and integers beyond IEEE-754 double precision lose accuracy. Very large documents are held in memory twice during the transform, once as the parsed tree and once as the rebuilt output, which is comfortable in a browser tab but not a plan for multi-hundred-megabyte files.

Finally, sorting destroys array order, which carries meaning far more often than key order does. For a sequence of events, a queue of pending operations, or any list where position is significant, set the `Sort arrays` control to None — that disables the dedupe checkbox too, so only `Sort object keys` applies and the array sequence survives untouched.

Frequently Asked Questions

How do I sort JSON by key?
Paste your JSON into the input and click Sort. Choose to sort by keys (alphabetically), by values, or both. Objects are sorted recursively. The tool also has an option to deduplicate array items.
Does sorting change my data?
No. Sorting only reorders key-value pairs within objects and item order within arrays. The data values themselves are never modified.
Is my data sent to a server?
No. Every tool on jsonversal runs entirely in your browser using the Web Crypto API, File API, and Clipboard API. Nothing is ever uploaded — not even the JSON you paste in.
Do I need an account or API key?
No signup, no email, no API key. All tools are free to use with no signup required.
Can I use these tools offline?
Yes. Once the page loads, all tools work offline. There are no external API calls or CDN dependencies at runtime.
🔒
Your data never leaves your device

All processing happens in your browser. No uploads, no tracking, no servers. Your API keys, configs, and private payloads stay private — 100% client-side.

esc
↑↓ navigate ↵ open esc close