express middleware to parse turtle body using n3

Usage no npm install needed!

<script type="module">
  import expressTurtleParser from '';



This is for express applications where you who want to parse Turtle RDF on HTTP POST.


While it has not been the most used or the most cited tool, the use of RDF is rising.

This uses n3 at its core. (

This was based on the very popular express-xml-bodyparser (


npm install express-turtle-parser


You can either use express-turtle-parser at application level, or for specific routes only.

Here is an example of an express application with default settings:

var express = require('express'),
    app = express(),
    http = require('http'),
    server = http.createServer(app),
    TurtleParser = require('express-turtle-parser');

app.use(TurtleParser());'/receive-turtle', function(req, res, next) {

  // req.triples array contains the parsed turtle

  // req.rawBody contains the raw file


# Save this in a file called provo-example.ttl 
# prov-o example from

@prefix xsd:  <> .
@prefix foaf: <> .
@prefix prov: <> .
@prefix :     <> .

   a prov:Entity;
   prov:wasGeneratedBy  :illustrationActivity;
   prov:wasDerivedFrom  :aggregatedByRegions;
   prov:wasAttributedTo :derek;

   a foaf:Person, prov:Agent;
   foaf:givenName       "Derek";
   foaf:mbox            <>;
   prov:actedOnBehalfOf :natonal_newspaper_inc;

   a foaf:Organization, prov:Agent;
   foaf:name "National Newspaper, Inc.";

   a prov:Activity; 
   prov:used              :aggregatedByRegions;
   prov:wasAssociatedWith :derek;
   prov:wasInformedBy     :aggregationActivity;

   a prov:Entity;
   prov:wasGeneratedBy  :aggregationActivity;
   prov:wasAttributedTo :derek;

   a prov:Activity;
   prov:startedAtTime    "2011-07-14T01:01:01Z"^^xsd:dateTime;
   prov:wasAssociatedWith :derek;
   prov:used              :crimeData;
   prov:used              :nationalRegionsList;
   prov:endedAtTime      "2011-07-14T02:02:02Z"^^xsd:dateTime;

   a prov:Entity;
   prov:wasAttributedTo :government;
:government a foaf:Organization, prov:Agent .

   a prov:Entity;
   prov:wasAttributedTo :civil_action_group;
:civil_action_group a foaf:Organization, prov:Agent .
// using curl to send a HTTP POST

cat provo-example.ttl | curl -H "Content-Type: text/turtle" -X POST -d @- http://localhost:43711/receive-turtle