A JSON-LD Context is the machine-readable document or inline object that maps the shorthand terms and prefixes used in a JSON-LD document to their fully qualified IRIs in a target vocabulary or ontology. It serves as the bridge between the compact, human-readable JSON representation and the globally unambiguous RDF data model, enabling semantic interoperability across disparate systems. Contexts may be embedded inline within a document, referenced by URL, or composed from multiple context documents. The JSON-LD 1.1 specification extends context capabilities with scoped contexts, type-scoped and property-scoped contexts, and protected terms that resist accidental overriding. Correct context design is foundational to knowledge graph compilation and Linked Data publication.
Content
- A JSON-LD Context document specifies prefix expansions (e.g. mapping “schema” to “https://schema.org/”), type coercions (ensuring numeric strings are interpreted as integers), language tagging for string literals, and base IRI declarations. When a JSON-LD processor encounters a term in a document, it looks up the term in the active context to produce the full IRI used in the output RDF graph. This allows compact, readable JSON to produce globally unambiguous statements.
- Context documents may be hosted at dereferenceable URLs, allowing them to be shared across documents and cached. The JSON-LD 1.1 specification introduced protected terms—context entries that raise an error if a nested context attempts to redefine them—critical for security-sensitive vocabularies like Verifiable Credentials. Scoped contexts allow different property definitions to apply within specific subtrees of a document, enabling rich, context-sensitive data modelling without namespace collisions.
- Practical context design involves careful vocabulary alignment with established ontologies such as Schema.org, Dublin Core, SKOS, and OWL. Well-designed contexts minimise redundancy, use established RDF vocabularies for common properties, and version-stamp the context IRI to enable graceful schema evolution. The W3C JSON-LD Working Group maintains the canonical context processing algorithm, and compliant processor libraries are available in JavaScript, Python, Java, Ruby, and PHP.
- In knowledge graph compilation pipelines such as this ontology, JSON-LD Contexts serve as the semantic glue between authoring-time compact notation and the Ontology IRIs required for SPARQL querying, OWL reasoning, and WebVOWL visualisation. A malformed context—mismatched prefixes, dangling term references, or invalid IRI syntax—will cause downstream compilation failures, underscoring the importance of context validation tooling such as the W3C JSON-LD Playground and jsonld.js.