Titanium JSON-LD 1.1 Processor & API

June 6, 2026 · View on GitHub

An implementation of the JSON-LD 1.1 (JSON-based Serialization for Linked Data) specification in Java.

✨ Features

  • No vibe coding. No generated code. Just deliberate engineering
  • Full conformance with the JSON-LD 1.1 specification
  • Secure, stable, high-performance implementation with ~3000 tests
  • Minimal external dependencies
  • Simple, easy-to-use API
  • Extensions (since v2.0):
    • JSON-LD-star expansion (experimental)
    • Processing policies: undefined terms, dropped values, time/space constraints
    • Generated TypeMap / TermMap (experimental)
    • Built-in loaders: HTTPS, file, classpath, scheme router, URI rewriter, LRUCache, in-memory
    • Generalized processing with tree-io (Jakarta JSON, Jackson, or anything else)

🎯 Status

Java 21 CI CodeQL Codacy Badge Codacy Badge Javadoc Maven Central License NO VIBE CODING AI

🧩 Libraries & Tools

✅ Conformance

FeatureTestsPassPass RateNotes
Expansion376376100%
Compaction244244100%
Flattening5555100%
JSON-LD to RDF45645499.6%
RDF to JSON-LD5252100%
Framing919098.9%
Remote Document and Context Retrieval181794.4%

📄 See also: EARL Results from the JSON-LD 1.1 Test Suite

💡 Examples

Titanium provides a high-level JsonLd API for working with JSON-LD documents.

Transformations

Perform standard JSON-LD operations such as expansion, compaction, flattening, framing, and conversion from/to RDF. The JSON-LD document to process can be remote or local.

// Expansion from a remote JSON-LD document
JsonLd.expand("https://w3c.github.io/json-ld-api/tests/expand/0001-in.jsonld")
      .ordered()
      .get();

// Expansion from a local file with an external context
JsonLd.expand("file:/home/filip/document.json")    // HTTP(S) and File schemes supported
      .context("file:/home/filip/context.jsonld")  // external context
      .get();

// Compaction with a remote context
JsonLd.compact("https://example/expanded.jsonld", "https://example/context.jsonld")
      .compactToRelative(false)  // use absolute IRIs
      .get();

// Flattening a JSON-LD document
JsonLd.flatten("https://example/document.jsonld").get();

// Convert JSON-LD to RDF
JsonLd.toRdf("https://example/document.jsonld").provide(RdfConsumer); 

// RDF Dataset Canonicalization with Titanium RDFC
var canonicalizer = new RdfCanon.create(...);
JsonLd.toRdf("https://example/document.jsonld").provide(canonicalizer);
canonicalizer.provide(RdfConsumer);
// or with N-Quads output
canonicalizer.provide(new NQuadsWriter(...));

// Convert RDF to JSON-LD
var consumer = JsonLd.fromRdf();
consumer.quad(...);  // feed manually or via a reader
(new NquadsReader(...)).provide(consumer);

// Get the final JSON-LD result
consumer.toJsonLd();

// Framing a document
JsonLd.frame("https://example/document.jsonld", "https://example/frame.jsonld").get();

Local JSON Document

Load and process JSON-LD documents directly from an InputStream or Reader.

// Load JSON from InputStream or Reader
Document document = JsonDocument.of(inputStream);
Document context = JsonDocument.of(reader);

// Expand the local document
JsonLd.expand(document).get();

// Compact using a local context
JsonLd.compact(document, context).get();

Processing Timeout [Experimental]

Set a maximum processing duration for JSON-LD operations. The timeout does not include time spent loading external documents.

// Terminates processing after the specified duration (excluding DocumentLoader time)
JsonLd.expand(document)
      .timeout(Duration.ofSeconds(5))
      .get();

HTTP Document Loader Timeout

Customize the HTTP loader to apply a read timeout when fetching remote JSON-LD or context documents.

// Configure a custom HTTP loader with a 30-second read timeout
static DocumentLoader LOADER = HttpLoader.defaultInstance().timeout(Duration.ofSeconds(30));
...
JsonLd.expand(...).loader(LOADER).get();

Document Caching

Use an LRU-based cache to reuse previously loaded documents and reduce network calls. A cache instance can be shared across multiple operations.

// LRU cache for remote documents (capacity = 100)
JsonLd.expand("https://example.com/document.jsonld")
      .loader(new LRUDocumentCache(loader, 100))
      .get();

// Reuse cache across multiple documents
DocumentLoader cachedLoader = new LRUDocumentCache(loader, 100);

JsonLd.expand("https://example.com/document.jsonld").loader(cachedLoader).get();
JsonLd.expand("https://example.com/another-document.jsonld").loader(cachedLoader).get();

Undefined Terms Processing Policy

Define how the processor handles terms not defined in the context. Options include Fail, Warn, or Ignore (default).

// Define behavior for undefined terms: Fail, Warn, or Ignore (default)
JsonLd.expand(document)
      .undefinedTermsPolicy(Fail)  // or Warn | Ignore
      .get();

📘 Learn more: See the Javadoc API Reference for advanced configuration and usage options.

⚙️ Installation

Titanium

Maven (Java 11+)

<dependency>
    <groupId>com.apicatalog</groupId>
    <artifactId>titanium-json-ld</artifactId>
    <version>1.7.0</version>
</dependency>

Gradle (Java 8+, Android API Level ≥ 24)

implementation("com.apicatalog:titanium-json-ld-jre8:1.7.0")

Warning

The upcoming 2.x version is under active development and requires Java 21 or higher. 2.x milestone releases are provided for testing and feedback purposes only and should not be used in production.

Each milestone can introduce breaking changes.

JSON-P Provider

Titanium v1.x.x relies on a JSON-P (Jakarta JSON Processing) provider. Ensure that one is available on your classpath.

Maven

<dependency>
    <groupId>org.glassfish</groupId>
    <artifactId>jakarta.json</artifactId>
    <version>2.0.1</version>
</dependency>

Gradle

implementation("org.glassfish:jakarta.json:2.0.1")

🤝 Contributing

Contributions of all kinds are welcome — whether it’s code, documentation, testing, or community support! Please open a pull request or issue to get started.

💻 Develop

  • Implement a new feature
  • Fix an existing issue or bug
  • Refactor or optimize existing code

🧪 Test

  • Report bugs or unexpected behavior
  • Add or improve unit/integration tests
  • Verify milestone builds and provide feedback

📖 Document

  • Write or improve Javadoc and inline comments
  • Create or update tutorials and usage guides
  • Proofread and improve clarity or accuracy in documentation

🌟 Promote

  • Star ⭐ and share the project
  • Write a blog post, article, or social media post about it
  • Help answer questions or guide new contributors

Your support helps sustain development.

🏗️ Building

Fork and clone the project repository.

Note

Version 2.0 is under active development! The new major version 2.0 requires Java 21 and is released in milestones before the final release.

Each milestone can introduce breaking changes and is intended only for testing.

> cd titanium-json-ld
> mvn package

📚 Resources

💼 Commercial Support

Commercial support and consulting are available. For inquiries, please contact: filip26@gmail.com