What are the Ontology Formats?

RDF is the underlying data model, but there are several serialization formats for writing it down. Each has trade-offs in readability, verbosity, and tool support.

The RDF Data Model

The Resource Description Framework (RDF) represents knowledge as a set of triples: subject – predicate – object. Subjects and predicates are IRIs; objects can be IRIs or literal values (strings, numbers, dates). A collection of triples forms a directed graph.

The format (or serialization) determines how those triples are written in a file. The same graph can be serialized in Turtle, RDF/XML, JSON-LD, or any other RDF format — the information content is identical.

Turtle

Turtle (Terse RDF Triple Language) is the most popular human-readable RDF format. It supports prefix abbreviations, multi-value shorthand with commas, and multi-predicate shorthand with semicolons. OntoKit uses Turtle as its canonical format.

@prefix ex:   <http://example.org/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl:  <http://www.w3.org/2002/07/owl#> .

ex:Animal a owl:Class ;
    rdfs:label "Animal"@en ;
    rdfs:comment "A living organism that feeds on organic matter."@en .

ex:Dog a owl:Class ;
    rdfs:subClassOf ex:Animal ;
    rdfs:label "Dog"@en .

RDF/XML

The original W3C serialization from 1999. Verbose but widely supported by XML toolchains. Harder for humans to read but excellent for machine-to-machine exchange.

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
         xmlns:owl="http://www.w3.org/2002/07/owl#">
  <owl:Class rdf:about="http://example.org/Animal">
    <rdfs:label xml:lang="en">Animal</rdfs:label>
  </owl:Class>
  <owl:Class rdf:about="http://example.org/Dog">
    <rdfs:subClassOf rdf:resource="http://example.org/Animal"/>
    <rdfs:label xml:lang="en">Dog</rdfs:label>
  </owl:Class>
</rdf:RDF>

N-Triples

A line-based format where each line is exactly one triple with full IRIs (no prefixes). Extremely simple to parse and ideal for streaming or bulk loading, but very verbose.

<http://example.org/Animal> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> .
<http://example.org/Animal> <http://www.w3.org/2000/01/rdf-schema#label> "Animal"@en .
<http://example.org/Dog> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> .
<http://example.org/Dog> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://example.org/Animal> .
<http://example.org/Dog> <http://www.w3.org/2000/01/rdf-schema#label> "Dog"@en .

JSON-LD

JSON-LD embeds RDF data in standard JSON using a @context block. Popular with web developers because it integrates directly with JavaScript and REST APIs. Used by Schema.org for structured data in web pages.

{
  "@context": {
    "ex": "http://example.org/",
    "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
    "owl": "http://www.w3.org/2002/07/owl#"
  },
  "@graph": [
    {
      "@id": "ex:Animal",
      "@type": "owl:Class",
      "rdfs:label": { "@value": "Animal", "@language": "en" }
    },
    {
      "@id": "ex:Dog",
      "@type": "owl:Class",
      "rdfs:subClassOf": { "@id": "ex:Animal" },
      "rdfs:label": { "@value": "Dog", "@language": "en" }
    }
  ]
}

Notation3 (N3)

N3 is a superset of Turtle that adds formulas, variables, and built-in predicates for expressing rules. While less common for publishing ontologies, it is used in reasoning and logic programming contexts.

Format Comparison

FormatReadabilityVerbosityBest For
TurtleHighLowHuman authoring, version control
RDF/XMLLowHighLegacy tools, XML pipelines
N-TriplesLowVery highBulk loading, streaming
JSON-LDMediumMediumWeb APIs, JavaScript apps
N3HighLowRules, logic programming

W3C Specifications