The JSON Canonicalization Scheme (JCS) defines a deterministic way to serialize JSON so that the same JSON data model always produces the same byte sequence.
This is critical for use cases such as digital signatures, hashing, and data integrity verification, where even small differences in whitespace, member ordering, or number formatting would otherwise break validation.
By normalizing JSON into a canonical form, JCS ensures interoperability across systems and guarantees stable, repeatable representations of data.
Titanium JCS is a Java implementation of the RFC 8785 JSON Canonicalization Scheme (JCS).
-
Canonical JSON Writer
Deterministically serializes JSON values into a stable, repeatable form following RFC 8785. -
Canonical JSON Equality Comparator
Compares JSON values for equality under JCS rules, ensuring numbers, objects, and arrays are compared in their canonical form rather than raw text.
// Canonicalize a JSON value and return the canonical string
var canonicalJson = Jcs.canonize(json);
// Canonicalize a JSON value and write canonical JSON to a writer
Jcs.canonize(json, writer);
// Compare two JSON values for canonical equality
if (Jcs.equals(json1, json2)) {
// values are equal under RFC 8785 rules
}
<dependency>
<groupId>com.apicatalog</groupId>
<artifactId>titanium-jcs</artifactId>
<version>1.1.1</version>
</dependency>
Ensure that the JSON-P provider is added to the classpath if it is not already present.
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>jakarta.json</artifactId>
<version>2.0.1</version>
</dependency>
LD-CLI is a command-line utility for working with JSON, JSON-LD, CBOR-LD, multiformats, and related specifications.
It provides encoding, decoding, detection, analysis, and format conversion features, making it useful for inspecting identifiers, testing content addressing, and integrating multiformats into development workflows.
Canonicalize JSON and write canonical JSON to stdout
cat test.json | ld-cli jcs
All PR's welcome!
Fork and clone the project repository.
> cd titanium-jcs
> mvn package
- RFC 8785 JSON Canonicalization Scheme (JCS)
- JSON Canonicalization Scheme (JCS)
- Titanium RDF Canon
- LD-CLI
Commercial support and consulting are available.
For inquiries, please contact: filip26@gmail.com