canonicaljson
Canonical JSON
Decision gist · record as of 2026-08-14
Yes. Canonicaljson solves a real problem—deterministic JSON serialization—that the standard library does not address. It has no dependencies, low install friction, active maintenance, a permissive license, and no known vulnerabilities. Install it if your application requires reproducible JSON encoding for signing, hashing, or comparison; skip it if you only need standard JSON serialization.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.7 or newer.
- Low friction: pure Python wheel with no runtime dependencies.
- Actively maintained as of 2026-05-06 with production-stable status since its 2015 release.
License · maintenance · safety
Apache License, Version 2.0 (permissive) — Apache License 2.0 (permissive) places no significant restrictions on use, modification, or distribution in proprietary or open-source projects.
last release 2023-03-15 (1248 days) · last repo commit 2026-05-06 · 30 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 272,563 downloads/mo, #8,208 on PyPI
Alternatives
Verify before relying
pip install canonicaljson
import canonicaljson
result = canonicaljson.encode_canonical_json({"key": "value"})
print(result) # b'{"key":"value"}'- Performance characteristics compared to standard library json for large objects.
- Whether the preserialisation callback mechanism covers all custom type use cases in practice.
What it is and what it does
Canonicaljson produces deterministic JSON output by enforcing a canonical form: object keys are always sorted, whitespace is eliminated, and character escaping follows RFC 7159 with minimal sequences. This makes the encoded output identical every time for the same input, which is essential for cryptographic signing, content hashing, and any system where reproducible serialization matters.
The package wraps either simplejson (by default on CPython) or the standard library json module (on PyPy) and adds a preserialisation hook system to handle custom types. It requires Python 3.7 or newer and has no external runtime dependencies, making it lightweight to integrate into existing projects.
Use it for
- Signing JSON data cryptographically: canonical form ensures signatures remain valid across different serialization libraries.
- Deduplicating or caching JSON objects: identical input always produces identical bytes, enabling content-addressed storage.
- Blockchain or ledger applications: deterministic encoding is critical for consensus and transaction verification.
- API request/response logging: canonical form makes log entries comparable and reduces storage by eliminating whitespace.
- Testing JSON-producing code: canonical output makes assertions on serialized data deterministic and independent of key order.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
Canonicaljson solves a real problem—deterministic JSON serialization—that the standard library does not address. It has no dependencies, low install friction, active maintenance, a permissive license, and no known vulnerabilities. Install it if your application requires reproducible JSON encoding for signing, hashing, or comparison; skip it if you only need standard JSON serialization.
Install
canonicaljson on PyPI
Before you install
Low friction: pure Python wheel with no runtime dependencies. Actively maintained as of 2026-05-06 with production-stable status since its 2015 release.
Requires Python 3.7 or newer.
License in practice
Apache License 2.0 (permissive) places no significant restrictions on use, modification, or distribution in proprietary or open-source projects.
Quickstart
pip install canonicaljson
import canonicaljson
result = canonicaljson.encode_canonical_json({"key": "value"})
print(result) # b'{"key":"value"}'
Verify before relying
- Performance characteristics compared to standard library json for large objects.
- Whether the preserialisation callback mechanism covers all custom type use cases in practice.
Package facts
| License | Apache License, Version 2.0 permissive |
| Python support | Supports the current Python release >=3.7 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 1,248 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 272,563 / month, #8,208 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseProgramming Language :: Python :: 2Programming Language :: Python :: 3 |
Evidence: canonicaljson-2.0.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “canonical json encoding”
- canonicaljsonEncodes Python objects to canonical JSON with sorted keys, minimal…
- jcsCanonicalizes JSON according to RFC 8785, producing a deterministic…
- canoserCanoser implements canonical serialization for Libra network data…
Give your agent the search over MCP, or paste the wish link into any chat.
More Software Development packages
Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.
Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.
Install it if you are building CLIs in Python.
Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.
See also jcs · rfc8785 · simplejson · jsonseq · json-encoder · canoser · rison · prison · numpyencoder · demjson3