JSON sort keys
ClientRecursively sort every object's keys for a canonical JSON text—useful before hashing, or to reduce noise in diffs. Array element order is left unchanged. All parsing and rewriting stay in your browser.
Learn more: sorted keys & canonical JSON text
Reorder keys at every object level so the same data always serializes the same way—helpful for stable file diffs, fingerprints, or comparing payloads when key order should not matter.
What gets sorted
Object property names are sorted in ascending Unicode order (using locale-aware string comparison). Nested objects are processed the same way. Arrays keep their element order—only object keys are rearranged.
Parsing limits
The page uses standard JSON parsing. If the same key appears more than once in the source text, the parser keeps one value (the usual JavaScript behavior)—fix the document in your editor if you need to preserve duplicates.
Related workflows
For pretty-print without reordering keys, use the JSON formatter. For structural differences between two documents, use JSON compare. For hashing or signing, pair sorted output with your chosen digest on the sorted text.
Editor & actions
?
Sort keys parses JSON and rewrites every object so keys appear in ascending Unicode order. Nested objects are sorted the same way. Array order is not reordered—only object keys. Use this for canonical text before hashing or for cleaner diffs. Parsing uses JSON.parse (duplicate keys in source text follow JavaScript rules: last occurrence wins).
This is not JSON Schema validation—pair with the JSON formatter if you only need pretty-print without reordering keys.
100 characters
Paste JSON, then sort object keys for stable diffs or hashing—arrays keep element order.
Common use cases
- Produce stable JSON text before diffing or code review so key order noise does not hide real changes.
- Normalize config or fixture files before hashing when only key order differs between environments.
- Prepare payloads for human-readable snapshots where a consistent key order helps scanning.
Common mistakes to avoid
Assuming sorted keys are a signing or JCS substitute
Sorting keys is not the same as RFC 8785 JCS. For signatures and strict canonical bytes, use the JCS tool instead.
Relying on array element reordering
This tool sorts object keys only. Array order is preserved because it usually carries meaning.
FAQ
Does sorting keys run locally?
Yes. Parse, reorder, and stringify happen in your browser.
Will Unicode key order match another language’s sort?
The tool uses a defined Unicode code-point order for keys. If you need bitwise-identical output across stacks, confirm the same ordering rules elsewhere or use JCS for canonical bytes.
More tools
Related utilities you can open in another tab—mostly client-side.
JSON canonicalization (JCS)
ClientRFC 8785 JCS: deterministic canonical JSON string and SHA-256—signing and hashing, client-side.
JSON formatter
ClientJSON format online: pretty-print, minify, validate, escape, download .json.
JSON compare
ClientSide-by-side diff paths; sample pre-filled.
Encoding tools
ClientBase64 and URL on this page; hub lists hex, HTML entities, JWT, JSON helpers, crypto, and tokens.