Knowledge Graph Languages & Structured Data Formats

Structured data formats are the notations used to write entities and relationships down, query them, and check them. There are more of them than the subject strictly needs, because they were designed at different times for different consumers: some describe data, some ask questions of it, some constrain it, and some exist only to move it in bulk. This section covers each one, and this page explains which is which so that nothing here is read as a competitor to something it has no overlap with.

The four jobs a format can do

Almost every question about which format to use dissolves once the formats are sorted by job.

Express data. RDF is the data model; Turtle, N-Triples, JSON-LD, RDFa, Microdata and RDF/XML are ways of writing it down. Any of them can carry the same facts, and a conformant parser produces the same graph from all of them.

Query data. SPARQL asks questions of an RDF graph and is the only query language in this section. Cypher and GQL query labeled property graphs instead, and are covered in property graph vs RDF.

Constrain data. OWL says what is logically true about a domain and lets a reasoner derive new facts. SHACL says what a valid graph must look like and reports what fails. They are complements, not alternatives.

Move data. JSONL is not a semantic format at all. It is a container that makes large files streamable, and it is how graph data usually travels in bulk.

The formats at a glance

Format Job Where it lives Who consumes it Spec body
RDF Data model plus its serializations Files, triple stores, HTTP responses Any RDF tool W3C
JSON-LD Express data as JSON A <script> tag in HTML, or an API response Search engines, RDF tools, JSON tools W3C
RDFa Express data in HTML attributes Attributes on visible markup Search engines, RDF parsers W3C
Microdata Express data in HTML attributes Attributes on visible markup Search engines WHATWG
Open Graph Describe a page for link previews <meta> tags in the head Social platforms, chat apps, some AI surfaces ogp.me
JSONL Move records in bulk Files and streams Data pipelines, warehouses, ML tooling jsonlines.org
SPARQL Query a graph Sent to an endpoint Triple stores, query services W3C
OWL Define an ontology and support reasoning Loaded beside the data Reasoners, ontology editors W3C
SHACL Validate a graph against shapes Loaded beside the data Validators, ingest pipelines, CI W3C

The three formats that compete

Only one group in this section contains genuine alternatives: the ways of putting schema.org data on a web page. JSON-LD, RDFa and Microdata express the same vocabulary and expand to the same triples, so the choice is about how the markup is maintained rather than what it means. Google reads all three and recommends JSON-LD.

  • JSON-LD keeps the data in one block, separate from the visible HTML. It is the easiest to generate, inject and audit, and the easiest to let drift out of sync with the page.
  • RDFa annotates the visible markup and can mix vocabularies through real prefixes, so it can carry schema.org and Dublin Core in the same document.
  • Microdata also annotates the visible markup, with a simpler attribute set and a single vocabulary per item.

The format comparison page puts the same fact in all three and gives the cases where an attribute format is still the better answer.

Open Graph looks like a fourth option and is not one. It is a different vocabulary for a different consumer: social and messaging platforms building a link preview. A page normally carries both Open Graph tags and schema.org markup, because nothing reads both.

Reading order

For a developer new to the stack, the productive path is RDF for the model, then SPARQL to query something real, then SHACL when data quality becomes the problem, and OWL only if reasoning turns out to be a requirement. The concepts underneath all of it are at Core Concepts, and triples in particular.

For an SEO, the path is JSON-LD, then the format comparison so the legacy markup on an inherited site makes sense, then Open Graph for link previews. The vocabulary those formats carry is schema.org, and the tactics are in Knowledge Graphs for SEO.

A note on what is not here

Turtle, N-Triples, TriG, N-Quads and RDF/XML are serializations of RDF rather than separate languages, so they are covered on the RDF page with the same example graph written in each. SKOS is a vocabulary for taxonomies rather than a language, and it sits on the ontologies page. Cypher and GQL belong to the property graph world and are compared with SPARQL in property graph vs RDF. Primary sources for every specification are indexed at specs and standards.

Frequently asked questions

Which structured data format should I use?

Use JSON-LD unless something specific rules it out. Google recommends it, it is the easiest to generate and validate, and it keeps the data separate from presentation markup. RDFa or Microdata are better when the markup must stay attached to content that non-developers edit, or when a CMS template already emits one of them and rewriting it would risk more than it gains.

Are JSON-LD, RDFa and Microdata really equivalent?

They are equivalent in meaning, not in convenience. All three express schema.org types and properties and expand to the same RDF triples, so a parser ends up with the same graph. They differ in where the markup lives, how easily it can be generated and audited, and which vocabularies can be mixed in one document.

Is Open Graph the same thing as schema.org markup?

No. Open Graph is a small vocabulary of og: meta tags that social platforms and messaging apps read to build a link preview. schema.org is a large vocabulary that search engines read to understand entities and generate rich results. They serve different consumers and a page should carry both.

What is the difference between OWL and SHACL?

OWL describes what is true about a domain so a reasoner can infer facts that were never stated, and it assumes an open world where missing data is unknown rather than false. SHACL describes what data must look like and reports violations, which is closed-world checking. Use OWL for inference and SHACL for data quality; many projects use both.

Sources and further reading

  • W3C. Semantic Web standards overview. https://www.w3.org/standards/semanticweb/
  • W3C. RDF 1.1 Primer. https://www.w3.org/TR/rdf11-primer/
  • W3C. JSON-LD 1.1. https://www.w3.org/TR/json-ld11/
  • WHATWG. HTML Standard, Microdata. https://html.spec.whatwg.org/multipage/microdata.html
  • The Open Graph protocol. https://ogp.me/
  • Google Search Central. Introduction to structured data markup. https://developers.google.com/search/docs/appearance/structured-data/intro-structured-data