JSON Sorter — Sort Object Keys Alphabetically Online
Alphabetically sort JSON object keys online. Optional deep sort, ascending / descending, and Minified / 2-space / Tab output. Useful for canonical form, cleaner diffs, and deterministic hashes. 100% local.
Last updated:
Paste JSON to reorder every object's keys alphabetically. Optional deep sort recurses into nested objects; array element order is preserved. Useful for canonical form, deterministic diffs, and stable content hashes.
What is JSON Sort?
Sorting the keys of a JSON object gives you a canonical (deterministic) representation that makes diffs dramatically smaller and lets you fingerprint content by hashing the serialized form. The technique matters wherever two different processes serialize 'the same' JSON but do so with different key orders — a common source of noise in code review, replication logs, and cache keys. This tool sorts keys with UTF-16 code-point ordering (the JS default, matching Python / Go / Java / RFC 8785) so results are portable across runtimes. Values are left untouched; array element order is preserved because it is semantically meaningful.
How to alphabetize JSON keys
- 1Paste your JSON into the input editor.
- 2Choose direction (A → Z or Z → A) and toggle 'Sort nested objects' for deep vs. shallow behavior.
- 3The output pane instantly shows the sorted JSON — pretty-printed or minified based on the indent setting.
- 4Copy the sorted JSON, or feed it through a hash function to fingerprint the content.
Tips & Best Practices
- ▸For strict RFC 8785 canonical JSON (used for signing), use a dedicated library — this tool covers key order but not the full number-normalization rules.
- ▸Sorting is useful before diffing two JSON files in a code review — reordered keys otherwise create noisy diffs even when nothing semantic changed.
- ▸Combine sort + minify to produce a stable content hash: JSON.stringify(sort(JSON.parse(input))) — identical inputs always hash to identical bytes.
Frequently Asked Questions
Why sort JSON keys?
Sorted keys give you a canonical form that makes diffs shrink dramatically (the same logical change no longer moves neighboring keys around), and it lets you hash two JSON documents and compare — a common trick for detecting content changes.
Does it sort array elements too?
No. Arrays are ordered by definition — sorting their elements would change semantics. Only object keys are sorted. If you want to sort by a specific field inside array elements, use jq or a small script.
Is this the same as RFC 8785 canonical JSON?
Close but not identical. RFC 8785 (JCS — JSON Canonicalization Scheme) also mandates a specific number serialization and UTF-16 code-point key ordering. This tool matches JCS on key order and uses JSON.stringify for values, which is equivalent for common cases (integers within safe range, standard strings). For full JCS compliance use a dedicated library.
How are Unicode keys sorted?
By UTF-16 code point (the default of JavaScript's < / > operators on strings). This matches Python, Go, and Java default string comparison and RFC 8785. If you need a locale-aware sort, post-process the output.
Related Tools
JSON Formatter
Format, beautify, and validate JSON online. Free, fast, and 100% local — your data never leaves your browser.
JSON Validator
Validate JSON online with instant error location and structure statistics (depth, keys, node types). 100% local — your JSON never leaves the browser.
JSON Schema Validator
Validate a JSON payload against a JSON Schema online. Supports Draft 2020-12, format validation (date-time, uuid, email, uri), and shows errors by JSON pointer path. 100% local — nothing is uploaded.
JSON Schema Generator
Generate a JSON Schema from a sample JSON — output as standard Draft 2020-12, OpenAI function calling schema, or Anthropic tool_use schema. Powers LLM structured output pipelines.
JSONPath Tester
Test JSONPath expressions against sample JSON online. Get instant, highlighted results for queries like $.store.book[*].author.
JSON Diff
Compare two JSON documents structurally and see added, removed, and changed values by path. Handles nested objects, arrays, and type changes.