RDF Serialization Formats: A Trends Comparison

Spread The Knowledge...

RDF Serialization Formats

In this post we include 12 of the most popular/prominent RDF serialization formats, starting with the original/oldest RDF/XML RDF serialization format, the scattered in the “XHTML document” RDFa serialization format, the currently most popular JSON-LD serialization format, the human-readable/compact RDF Turtle serialization format, the performant Hex-Tuples serialization format, the compact/compressed/binary HDT serialization format, the RDF-star/RDF Turtle-star serialization format that permits the definition/bridge to the Labelled Property Graphs (LPG) model among others:

RDF Serialization Formats

  • RDF/XML: RDF/XML 1.1 a W3C Recommendation on the 25 February 2014 is an XML syntax for expressing RDF graphs as XML documents. It was the very first syntax for expressing RDF Graphs and it is more focused on expressing machine-readable RDF graphs via verbose representations.
  • RDFa: RDFa 1.1 is a W3C Recommendation on the 17th of March of 2015 used for the purpose of adding attribute-level extensions to HTML, XHTML, and XML-based document types for embedding RDF data.
  • RDF N-Triples: RDF N-Triples 1.1 a W3C Recommendation also on the 25 February 2014  being a line-based, plain text serialization format for RDF graphs, and a subset of the Turtle format.
  • RDF Turtle: RDF 1.1 Turtle Terse RDF Triple Language is a W3C Recommendation 25 February 2014 whose syntax is similar to that of SPARQL written in a compact and natural text form, with abbreviations for common usage patterns and datatypes. It is a very popular RDF serialization format being human-readable and a superset of the line-based N-Triples format.
  • RDF TriG: RDF 1.1 TriG a W3C Recommendation also on 25 February 2014, written in a compact and natural text form, with abbreviations for common usage patterns and datatypes being an extension of the Turtle serialization format.
  • JSON-LD: a lightweight Linked Data format which currently is a W3C Proposed Recommendation on the 16th July 2020, human-readable/writing based upon the JSON format and providing a data format ideal for programming environments, REST Web services, and document-based No-SQL databases.
  • N-Quads: a W3C Recommendation also on 25 February 2014 which is line-based, plain text format for encoding RDF data in Subject-Predicate-Object sentences also containing a 4th optional component indicating the graph in a dataset the triple belongs otherwise the triple belongs to the default graph
  • N3-Notation3: N3 a W3C submission that was designed with human-readability consumption and developed by Sir Tim Berners-Lee and others from the Semantic Web community. N3 has several features that go beyond the serialization of RDF models from which RDF-Turtle is a simplified RDF-only subset of N3.
  • TRIX: Triples in XML is a practically deprecated XML-based serialization format for RDF Named Graphs and RDF Datasets which offers a compact and readable alternative to the XML-based RDF/XML syntax.
  • Hex-Tuples: HexTuples is a performant RDF serialization format/simple data model for dealing with linked data. A HexTuple consists of six fields: subject, predicate, value, datatype, language, and graph. It benefits from highly optimized JSON parsers in browsers.
  • HDT: HDT (Header, Dictionary, Triples) is an open-source/in progress of standardization (W3C HDT Member Submission) compact data structure and binary serialization format for RDF that compresses RDF datasets saving space while maintaining search and browse operations without prior decompression. Most parts of the data can be kept in main memory, which makes it an ideal format for storing and sharing RDF datasets on the Web. The size of the files is much smaller which means less bandwidth consumption for both producers/consumers. HDT is read-only which enables the use of fast/performant multi-threading programming. 
  • RDF-star:  RDF star or extended RDF is currently a proposed draft recommendation on the 8th December 2022 and covers the lack of a convenient way to annotate RDF triples and to query annotations as done natively in other graph data models such as edge properties in the “Property Graph” model. Whereas some previously proposed solutions relied on making use of reification annotating RDF statements with certainty scores, weights, temporal restrictions, and provenance information, these suffered from being too verbose and redundant. Olaf Hartig proposed RDF-star/RDF Turtle-star/SPARQL-star as an alternative approach that is based upon the nesting of RDF triples and of query patterns allowing a compact representation of RDF data and SPARQL queries, which is backward-compatible with the RDF/SPARQL standards, backed by a solid formal theoretical model, permitting the interoperability/conversion between the triple-based RDF model and the Property Graphs models, and also permitting more specific annotation-related extensions of RDF and SPARQL such as temporal or probabilistic extensions. RDF-star extends RDF by allowing arbitrarily deeply nested triples given the assumption that triples representing/annotating metadata about another triple may directly contain the annotated triple as its subject or object. In other words, RDF-star permits the non-verbose representation of data and the corresponding metadata, in the form of nested triples.

In the appendix, we include/show examples of each of these 12 RDF serialization formats.

Here we include Google Trends for the most prominent serialization formats in the latest 5 years.


It can be seen that the JSON-LD serialization format has been substantially more popular (in the latest 5 years) than the rest of serialization formats. The second most popular serialization format is RDF Turtle but far apart from JSON-LD. Most probably is that JSON-LD has been more popular among developers given that is both readible for humans and easily consumed by machines. RDF Turtle is quite popular in the Semantic Web Academic arena

Appendix: RDF Serialization Examples

We are going to show an RDF Graph depicting a subset of the University domain:

RDF Graph About Joe Doe

RDF/XML Serialization Example

<?xml version="1.0" encoding="utf-8" ?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:ns0="http://www.myschema.org/"
         xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">

  <rdf:Description rdf:about="http://www.university.org/joe-doe">
    <ns0:age rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">50</ns0:age>
    <ns0:city-address>Sydney, Australia</ns0:city-address>
    <ns0:title>PhD</ns0:title>
    <ns0:position>full-professor</ns0:position>
    <ns0:university>
      <rdf:Description rdf:about="http://www.university.org/sydney-uni">
        <rdfs:label xml:lang="en">University of Sydney</rdfs:label>
      </rdf:Description>
    </ns0:university>
  </rdf:Description>
</rdf:RDF>

RDF N-Triples Serialization Example

<http://www.university.org/joe-doe> <http://www.myschema.org/age> "50"^^<http://www.w3.org/2001/XMLSchema#integer> .
<http://www.university.org/joe-doe> <http://www.myschema.org/city-address> "Sydney, Australia" .
<http://www.university.org/joe-doe> <http://www.myschema.org/title> "PhD" .
<http://www.university.org/joe-doe> <http://www.myschema.org/position> "full-professor" .
<http://www.university.org/joe-doe> <http://www.myschema.org/university> <http://www.university.org/sydney-uni> .
<http://www.university.org/sydney-uni> <http://www.w3.org/2000/01/rdf-schema#label> "University of Sydney"@en .

RDF Turtle Serialization Example

@prefix uni:<http://www.university.org/>.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
@prefix ex:<http://www.myschema.org/>.

uni:joe-doe ex:age "50"^^xsd:integer;
ex:city-address "Sydney, Australia";
ex:title "PhD";
ex:position "full-professor";
ex:university uni:sydney-uni.
uni:sydney-uni rdfs:label "University of Sydney"@en.

JSON-LD Serialization Example

[
  {
    "@id": "http://www.university.org/joe-doe",
    "http://www.myschema.org/age": [
      {
        "@value": 50
      }
    ],
    "http://www.myschema.org/city-address": [
      {
        "@value": "Sydney, Australia"
      }
    ],
    "http://www.myschema.org/position": [
      {
        "@value": "full-professor"
      }
    ],
    "http://www.myschema.org/title": [
      {
        "@value": "PhD"
      }
    ],
    "http://www.myschema.org/university": [
      {
        "@id": "http://www.university.org/sydney-uni"
      }
    ]
  },
  {
    "@id": "http://www.university.org/sydney-uni",
    "http://www.w3.org/2000/01/rdf-schema#label": [
      {
        "@language": "en",
        "@value": "University of Sydney"
      }
    ]
  }
]
  • N-Quads Serialization Example
  • <http://www.university.org/joe-doe> <http://www.myschema.org/age> "50"^^<http://www.w3.org/2001/XMLSchema#integer> <http://example.org/graph1>.
    <http://www.university.org/joe-doe> <http://www.myschema.org/city-address> "Sydney, Australia" <http://example.org/graph1>.
    <http://www.university.org/joe-doe> <http://www.myschema.org/position> "full-professor" <http://example.org/graph1>.
    <http://www.university.org/joe-doe> <http://www.myschema.org/title> "PhD" <http://example.org/graph1>.
    <http://www.university.org/joe-doe> <http://www.myschema.org/university> <http://www.university.org/sydney-uni> <http://example.org/graph1>.
    <http://www.university.org/sydney-uni> <http://www.w3.org/2000/01/rdf-schema#label> "University of Sydney"@en <http://example.org/graph2>.

    N3-Notation3 Serialization Example

    @prefix ns0: <http://www.myschema.org/> .
    @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
    
    <http://www.university.org/joe-doe>
      ns0:age 50 ;
      ns0:city-address "Sydney, Australia" ;
      ns0:title "PhD" ;
      ns0:position "full-professor" ;
      ns0:university <http://www.university.org/sydney-uni> .
    
    <http://www.university.org/sydney-uni> rdfs:label "University of Sydney"@en .

    Hex-Tuples Serialization Example

    ["http://www.university.org/joe-doe", "http://www.myschema.org/university", "http://www.university.org/sydney-uni", "globalId", "", ""]
    ["http://www.university.org/joe-doe", "http://www.myschema.org/position", "full-professor", "http://www.w3.org/2001/XMLSchema#string", "", ""]
    ["http://www.university.org/joe-doe", "http://www.myschema.org/city-address", "Sydney, Australia", "http://www.w3.org/2001/XMLSchema#string", "", ""]
    ["http://www.university.org/joe-doe", "http://www.myschema.org/age", "50", "http://www.w3.org/2001/XMLSchema#integer", "", ""]
    ["http://www.university.org/joe-doe", "http://www.myschema.org/title", "PhD", "http://www.w3.org/2001/XMLSchema#string", "", ""]
    ["http://www.university.org/sydney-uni", "http://www.w3.org/2000/01/rdf-schema#label", "University of Sydney", "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString", "en", ""]

    RDF-star Turtle-star Serialization Example

    RDF Graph Turtle-star About Joe Doe

    @prefix uni:<http://www.university.org/>.
    @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
    @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
    @prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
    @prefix ex:<http://www.myschema.org/>.
    
    <<uni:joe-doe ex:age "50"^^xsd:integer>> ex:certainty 0.9.
    <<uni:joe-doe ex:city-address "Sydney, Australia">> ex:certainty 0.9.
    <<uni:joe-doe ex:title "PhD">> ex:certainty 0.9.
    <<uni:joe-doe ex:position "full-professor">> ex:certainty 0.9.
    <<uni:joe-doe ex:university uni:sydney-uni>> ex:source uni:registry.
    uni:sydney-uni rdfs:label "University of Sydney"@en.

    RDF Trix Serialization Example. This serialization example has been generated via the RDFlib library.

    <TriX
      xmlns:owl="http://www.w3.org/2002/07/owl#"
      xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
      xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
      xmlns:xml="http://www.w3.org/XML/1998/namespace"
      xmlns="http://www.w3.org/2004/03/trix/trix-1/"
    >
      <graph>
        <uri>graph1</uri>
        <triple>
          <uri>joe-doe</uri>
          <uri>position</uri>
          <plainLiteral>"full-professor"</plainLiteral>
        </triple>
        <triple>
          <uri>joe-doe</uri>
          <uri>age</uri>
          <typedLiteral datatype="http://www.w3.org/2001/XMLSchema#integer">50</typedLiteral>
        </triple>
        <triple>
          <uri>joe-doe</uri>
          <uri>city-address</uri>
          <plainLiteral>"Sydney, Australia"</plainLiteral>
        </triple>
        <triple>
          <uri>joe-doe</uri>
          <uri>title</uri>
          <plainLiteral>PhD</plainLiteral>
        </triple>
        <triple>
          <uri>joe-doe</uri>
          <uri>university</uri>
          <uri>sydney-uni</uri>
        </triple>
      </graph>
      <graph>
        <uri>graph2</uri>
        <triple>
          <uri>sydney-uni</uri>
          <uri>rdfs-label</uri>
          <plainLiteral>"Sydney University"</plainLiteral>
        </triple>
      </graph>
      <graph>
        <uri>urn:x-rdflib:default</uri>
      </graph>
    </TriX>

    RDF TriG Serialization Example. This serialization example has been generated via the RDFlib library.

    @prefix ex: <http://www.myschema.org/> .
    @prefix ns1: <urn:x-rdflib:> .
    @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
    @prefix uni: <http://www.university.org/> .
    @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
    
    uni:G1 {
        uni:joe-doe ex:age 50 ;
            ex:city-address "Sydney, Australia" ;
            ex:position "full-professor" ;
            ex:title "PhD" ;
            ex:university uni:sydney-uni .
    }
    
    uni:G2 {
        uni:sydney-uni rdfs:label "University of Sydney"@en .
    }
    Print Friendly, PDF & Email

    Spread The Knowledge...