Protocols
Saved & recent

Canonicalization

Also called: canonical encoding, JSON Canonicalization Scheme, JCS

Canonicalization gives data a precisely defined representation so independent systems can produce the same bytes. This matters when hashing or signing structured messages: whitespace or property order can change the bytes even when a reader interprets the same object. Both sides must use the same canonicalization rules.

For example, JSON objects written with b before a or with a before b can become the same canonical text under the JSON Canonicalization Scheme. JCS defines property ordering and number serialization while preserving array order; it does more than remove spaces. Its input constraints also matter, and it does not normalize Unicode strings. Canonical bytes support consistent verification but do not themselves prove who created the data.

Read first
Serialization
Related
Serialization, Concise Binary Object Representation, Protocol conformance
Further reading
IETF — RFC 8785, JSON Canonicalization Scheme
{"b":2,"a":1} { "a": 1, "b": 2 } JCS canonicalization {"a":1,"b":2} identical UTF-8 bytes hash array order preserved [3, 1] → [3, 1] separate authentication step
Under the same JCS rules, these differently formatted objects produce identical canonical bytes for hashing or signing.

View in the full Protocols collection