--- id: rfc8785 version: "0.1.4" license: unclear license_treatment: permissive maintenance: active --- # rfc8785 — A pure-Python implementation of RFC 8785 (JSON Canonicalization Scheme) License: permissive · Maintenance: active · Downloads: 2.5M/mo ## What it is and what it does rfc8785 is a pure-Python implementation of RFC 8785, the JSON Canonicalization Scheme (JCS), which produces a single canonical byte representation of JSON data. It takes any JSON-serializable Python object and outputs UTF-8-encoded bytes in a deterministic form: keys are sorted alphabetically, whitespace is minimized, and the output is always identical for logically equivalent inputs. This is essential for cryptographic operations, digital signatures, and any scenario where you need byte-for-byte reproducible JSON. The package has zero runtime dependencies and works with Python 3.8 or later. It provides two main APIs: `dumps()` for in-memory serialization and `dump()` for writing directly to a file-like object. All serialization failures raise `CanonicalizationError`. The implementation differs from Andrew Rundgren's reference implementation in three ways: it requires explicit string conversion for non-string dictionary keys, provides no pretty-printing options, and always outputs minimally encoded UTF-8 bytes. Use it for: - Sign JSON data cryptographically by canonicalizing it first to ensure signatures remain valid across systems. - Deduplicate JSON objects in a database or cache by comparing their canonical forms. - Verify that two JSON structures are logically identical despite differences in formatting or key order. - Build deterministic content hashes for JSON payloads in APIs or distributed systems. - Implement JWS (JSON Web Signature) or other standards that require canonical JSON representation. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Implements RFC 8785 (JSON Canonicalization Scheme) to produce deterministic, byte-for-byte identical JSON serialization regardless of input order or representation. Yes. The package solves a specific, well-defined problem (RFC 8785 compliance) with zero dependencies, active maintenance, no known vulnerabilities, and permissive licensing. Install it if you need deterministic JSON serialization for cryptography, signatures, or any use case where byte-for-byte reproducibility matters. ## Install pip install rfc8785 uv add rfc8785 poetry add rfc8785 ## Installing rfc8785 Before you install: Low friction: pure Python with no runtime dependencies, distributed as a wheel. Actively maintained with a recent commit history and no known vulnerabilities. License in practice: Permissive Apache License 2.0 allows commercial and private use with minimal restrictions; suitable for most projects. Quickstart: import rfc8785 data = {"key": "value", "another": [1, 2, 3]} canonical_bytes = rfc8785.dumps(data) # Returns: b'{"another":[1,2,3],"key":"value"}' Requires Python 3.8 or later; non-string dictionary keys must be explicitly converted to strings before serialization. Verify before relying: - Whether the package handles very large JSON structures efficiently or has memory/performance constraints. - Compatibility with Python 3.13+ beyond the stated 'current' support window. ## Package facts - License: not declared (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 2.5M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags json canonicalization, rfc 8785 implementation, deterministic json serialization, json canonical form, jcs json scheme, json-canonicalization, cryptography-adjacent, zero-dependencies [View on SkillFed](https://skillfed.io/packages/rfc8785) · [View on PyPI](https://pypi.org/project/rfc8785/)