Javascript RDF library for browsers and Node.js.
owl:sameAs, and owl:{f,inverseF}unctionPropertySee:
The API documentation is partial but useful
for more information.
npm install rdflib
<script> file to include)git clone git@github.com:linkeddata/rdflib.js.git;
cd rdflib.js;
npm install;
Generate the dist directory
npm run build:browser
Make sure you have Node.js and Node Package Manager (npm) installed.
npm install --save rdflib
The Turtle/N3/JSON‑LD serializers accept an optional flags string to tweak output formatting and abbreviation behavior.
serialize(...):import { graph, serialize, sym } from 'rdflib'
const kb = graph()
const doc = sym('http://example.com/doc')
// ... add some statements ...
// Example: prevent dotted local parts in prefixed names
const turtle = serialize(doc, kb, doc.value, 'text/turtle', undefined, { flags: 'o' })
Common flags used internally (you can combine them, e.g. 'o k'):
s i – used by default for Turtle to suppress =, => notationsd e i n p r s t u x – used for N-Triples/N-Quads to simplify outputdr – used with JSON‑LD conversion (no default, no relative prefix)o – new: do not abbreviate to a prefixed name when the local part contains a dot. This keeps IRIs like
http://example.org/ns/subject.example in <...> form instead of ns:subject.example.Notes:
o) are honored.'p' disables prefix abbreviations entirely (all terms are written as <...> IRIs).dist: Where the bundled libraries are built. Run npm run build to generate them.test: Tests are here.lib: Transpiled, non-bundled library is built here when the library is
published to npm.- XMLHTTPRequest (Node.js version)
Thanks to the many contributors who have been involved along the way. LinkedData team & TimBL
MIT