Inferensys

Glossary

Turtle Format

Turtle (Terse RDF Triple Language) is a compact, human-readable syntax for writing RDF graphs, commonly used for serializing ontologies and knowledge bases.
Knowledge engineer constructing knowledge base on laptop, document hierarchy visible, casual office setup.
RDF SERIALIZATION

What is Turtle Format?

Turtle (Terse RDF Triple Language) is a compact, human-readable syntax for writing RDF graphs, commonly used for serializing ontologies and knowledge bases.

Turtle Format is a textual syntax for expressing Resource Description Framework (RDF) graphs as a sequence of subject-predicate-object triples. It provides a more compact and readable alternative to RDF/XML, using prefixes to abbreviate long IRIs and punctuation like semicolons and commas to list multiple predicates and objects for a single subject.

A core feature of Turtle is its support for @prefix declarations, which bind namespace IRIs to short labels, significantly reducing verbosity. The format is the foundation for the W3C standard TriG, which extends Turtle to support named graphs, making it essential for serializing entire knowledge graph datasets in a single, manageable file.

RDF SERIALIZATION

Key Features of Turtle

Turtle (Terse RDF Triple Language) provides a compact, human-readable syntax for writing RDF graphs. It is the preferred format for authoring ontologies and knowledge bases due to its clarity and expressiveness.

01

Compact Triple Syntax

Turtle serializes RDF data as subject-predicate-object triples, terminated by a period. It eliminates the verbosity of RDF/XML by using IRI prefixes and blank node identifiers.

  • Prefix Declaration: @prefix schema: <https://schema.org/> .
  • Triple Example: schema:Book schema:author "Jane Doe" .
  • Object Lists: Use commas to separate multiple objects for the same subject and predicate.
02

Predicate-Object Lists

Turtle reduces repetition by allowing a single subject to have multiple predicates and objects grouped together using semicolons (;) and commas (,).

  • Semicolons: Introduce a new predicate for the same subject.
  • Commas: Introduce a new object for the same predicate.
  • This syntactic sugar makes authoring complex entity descriptions significantly more efficient and readable than flat triple formats.
03

Datatype and Language Tags

Turtle supports explicit datatype annotation for literal values and language tagging for multilingual strings, ensuring semantic precision.

  • Datatypes: "42"^^xsd:integer or "2024-01-01"^^xsd:date
  • Language Tags: "Hello"@en or "Bonjour"@fr
  • This prevents ambiguity in knowledge graph ingestion, distinguishing a string from a number or a date.
04

Blank Nodes and Collections

Turtle provides shorthand for blank nodes (resources without a global IRI) and RDF collections (ordered lists).

  • Blank Node Shorthand: Use square brackets [ schema:name "Anonymous" ] to create an inline anonymous resource.
  • Collection Syntax: Use parentheses ( schema:Chapter1 schema:Chapter2 ) to represent a closed list.
  • These constructs are essential for modeling complex, nested structures without generating synthetic URIs.
05

Base IRI and Prefix Mapping

Turtle uses @base and @prefix directives to resolve relative IRIs, drastically shortening the serialization.

  • Base IRI: @base <https://example.com/data/> .
  • Prefix Mapping: @prefix foaf: <http://xmlns.com/foaf/0.1/> .
  • This allows authors to write foaf:Person instead of the full URI, making the document human-writable and reducing file size.
06

Graph Serialization Standard

Turtle is a W3C standard and the most widely used format for exchanging ontologies and SHACL shapes. It is fully compatible with SPARQL query syntax.

  • MIME Type: text/turtle
  • File Extension: .ttl
  • It serves as the bridge between human-authored semantic models and machine-optimized formats like N-Triples or JSON-LD.
SERIALIZATION COMPARISON

Turtle vs. Other RDF Serializations

A technical comparison of common RDF serialization formats based on syntax, readability, and use cases for knowledge graph and ontology engineering.

FeatureTurtleRDF/XMLJSON-LDN-Triples

Human Readability

High

Low

Medium

Low

Line-by-line Parsing

Compact Syntax

Native JSON Compatibility

Streaming Support

W3C Recommendation

Typical File Size

Small

Large

Medium

Very Large

Primary Use Case

Ontology authoring

Legacy systems

Web APIs

Data dumps

TURTLE FORMAT

Frequently Asked Questions

Clear, concise answers to the most common technical questions about the Terse RDF Triple Language (Turtle) and its role in semantic data serialization.

Turtle (Terse RDF Triple Language) is a syntax and file format for serializing Resource Description Framework (RDF) graphs. It works by expressing data as a sequence of subject-predicate-object statements, called triples, terminated by a period. Turtle is designed to be highly compact and human-readable compared to XML-based RDF serializations like RDF/XML. It achieves this by using URIs enclosed in angle brackets (<http://example.org/entity>) or prefixed names (schema:name), literals enclosed in quotation marks, and significant whitespace for separation. The format allows for abbreviation mechanisms like the semicolon (;) to repeat a subject and the comma (,) to repeat a predicate, drastically reducing verbosity when describing multiple properties of the same entity. This makes it the preferred format for authoring and reading ontologies, knowledge graphs, and linked data manually.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.