
json-canon: A Strict RFC 8785 Implementation in Go for Deterministic JSON
JSON is not deterministic. Object key order, number formatting, and whitespace vary across serializers, languages, and runtime versions. For most applications this doesn’t matter. For systems that sign, hash, or compare JSON by its raw bytes, it is a correctness failure. RFC 8785 — the JSON Canonicalization Scheme (JCS) — defines a canonical form that eliminates this nondeterminism. It specifies lexicographic key sorting, ECMAScript-compatible number serialization, and I-JSON constraints to produce byte-identical output for logically equivalent data. json-canon is an infrastructure-grade RFC 8785 implementation in pure Go. v0.2.0 was released on February 27, 2026. This post explains why it was built, the engineering decisions behind it, and who it is for. The problem in practice Consider two services that independently serialize the same data structure. One produces {"amount":1e2} and the other produces {"amount":100} . Both are valid JSON representing the same value. If either system
Continue reading on Dev.to
Opens in a new tab



