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).
-
Non-recursive 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. -
Uniform, JSON Library-Agnostic API
Built on a uniform Tree I/O API for JSON data processing.
Jackson and Jakarta are supported out of the box.
// Canonicalize a JSON value and return the canonical string
var canonicalJson = Jcs.canonize(json, adapter);
// Canonicalize a JSON value and write canonical JSON to a writer
Jcs.canonize(json, adapter, writer);
// Compare two JSON values for canonical equality
if (Jcs.equals(json1, json2, adapter)) {
// values are equal under RFC 8785 rules
}
<dependency>
<groupId>com.apicatalog</groupId>
<artifactId>titanium-jcs</artifactId>
<version>${titanium-jcs.version}</version>
</dependency>
<!-- Include at least one Tree I/O JSON adapter -->
<!-- Jackson 2 -->
<dependency>
<groupId>com.apicatalog</groupId>
<artifactId>tree-io-jackson2</artifactId>
<version>${tree-io.version}</version>
</dependency>
<!-- Jakarta (JSONP) -->
<dependency>
<groupId>com.apicatalog</groupId>
<artifactId>tree-io-jakarta</artifactId>
<version>${tree-io.version}</version>
</dependency>
<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
Contributions are welcome! Please submit a pull request.
Fork and clone the repository, then build with Maven:
> cd titanium-jcs
> mvn package
- RFC 8785 JSON Canonicalization Scheme (JCS)
- JSON Canonicalization Scheme (JCS)
- Tree I/O
- Titanium RDF Canon
- LD-CLI
Commercial support and consulting are available.
For inquiries, please contact: [email protected]