RFC 8785: JSON Canonicalization Scheme (JCS)
RFC 8785 defines the JSON Canonicalization Scheme (JCS), a deterministic serialization of I-JSON data for reliable hashing and signing, using ECMAScript number formatting, UTF-16 property sorting, and UTF-8 output.
Overview
RFC 8785, the JSON Canonicalization Scheme (JCS), specifies a deterministic way to serialize JSON so that the same logical data always yields the same byte sequence. This lets cryptographic operations such as hashing and signing produce identical results at producer and consumer, while the data itself can still travel on the wire in its original, unmodified form. Authored by Anders Rundgren, Bret Jordan, and Samuel Erdtman, it was published in June 2020 as an Informational RFC via the Independent Submission stream (not IETF standards-track). It builds on the I-JSON profile (RFC 7493) and reuses ECMAScript’s JSON.stringify() serialization semantics for primitives.
Key points
- Input must conform to I-JSON (RFC 7493): no duplicate property names, strings expressible as Unicode, and numbers representable as IEEE 754 double-precision values.
- Object properties are sorted into ascending lexicographic order by their UTF-16 code units, applied recursively to nested objects; array element order is preserved.
- Numbers are formatted per ECMAScript number-to-string rules over IEEE 754 doubles; the RFC cites the Ryu algorithm and V8 as reference behavior for shortest round-trip output.
- All whitespace between tokens is removed, and strings use minimal escaping: predefined short escapes (
\b,\t,\n,\f,\r),\uhhhhfor other control characters (U+0000 to U+001F), and\\/\"for backslash and quote. - The canonical result is emitted as UTF-8 bytes, making it directly suitable as a hash or signature input.
- Because canonicalization is a purely local transform, a signed JSON object can remain valid, human-readable JSON rather than an opaque encoded blob.
Relevance to Truestamp
JCS is the kind of deterministic canonicalization needed before user-supplied JSON claims can be reduced to a stable hash: without it, semantically identical objects with different key ordering or whitespace would hash differently and break verification. It is directly related to how Truestamp derives a stable digest from structured claim data feeding its domain-separated hashing and to the reproducibility guarantees of the proof bundle format.
Citations
- RFC 8785: JSON Canonicalization Scheme (JCS). Rundgren, Jordan, and Erdtman; Informational RFC, Independent Submission, June 2020.