JSON Canonicalization Scheme
JSON Canonicalization Scheme defines a repeatable UTF-8 representation of constrained JSON data for hashing and signing.
Rules: JCS uses ECMAScript primitive serialization and recursive object-property ordering by UTF-16 code units. Array order stays intact, and Unicode strings are not normalized. RFC 8785 is Informational, not an Internet Standards Track specification. [1]
Input: I-JSON prohibits duplicate object names, unpaired surrogates and Unicode noncharacters. Its interoperability guidance bounds numeric precision; identifiers requiring larger exact integers can use strings. Validation must occur before a parser discards evidence such as duplicate names. [2]
Scope: Repeatable output from a particular serializer is insufficient to establish a shared canonical format. Protocol Buffers warns that schema, build and library changes can alter deterministic output. [3]
Use: Agree on the representation profile and required application fields before comparing hashes. A canonical representation does not authenticate its reference or establish freshness. Selected rule examples distinguish ordering, normalization and input acceptance. [4]
Implementation trap: Rebuilding an ordinary JavaScript object from sorted keys does not preserve JCS order for array-index names: enumeration places 2 before 10, while UTF-16 comparison places 10 before 2. The linked probe includes a non-index-name control. [4] [5]
Relations
- related
- Concise Binary Object Representation, I-JSON, Data serialization, Cryptographic hash function
Citations
- RFC 8785: JSON Canonicalization Scheme, sections 3.1-3.2.4 and status
- RFC 7493: I-JSON numbers, characters and object constraints, sections 2.1-2.3
- Protocol Buffers: Proto Serialization Is Not Canonical
- Hesela: JSON canonicalization rule examples in storage integrity
- ECMAScript 2025: OrdinaryOwnPropertyKeys
Sources & caveats
- Source synthesis of RFC 8785 and I-JSON, with original selected-input examples rather than a full canonicalizer or JCS conformance suite.
- The linked examples perform no storage I/O and do not measure durability, corruption frequency or production security.