Chris Collins

Tools · infra

SPARQL and RDF playground

A real SPARQL 1.1 engine (Oxigraph, in WebAssembly) in the page — load Turtle, TriG, N-Triples or JSON-LD, run SELECT, CONSTRUCT, ASK, DESCRIBE and updates, see results as a table, as Turtle or as a graph drawing, work through labs on property paths, aggregates, named graphs and RDFS inference by rules, or query Wikidata.

Added

How to use it

RDF stores facts as triples — subject, predicate, object — with IRIs as names, and SPARQL queries them by pattern. This page runs Oxigraph, a SPARQL 1.1 database written in Rust, compiled to WebAssembly and loaded from jsDelivr when the page opens (about 1 MB). Everything you load and query stays in the page.

There are four small datasets written for the page — films with their cast and directors, a made-up family over five generations, the Solar System with some moons, and a FOAF social graph split into named graphs — and seven labs that walk through the language with them.

How to use it

Query. Write SPARQL and press Run (Ctrl/⌘+Enter). SELECT results show as a sortable table, as aligned text or as SPARQL JSON, and download as CSV or JSON. CONSTRUCT and DESCRIBE results show as a drawing (drag nodes about; click one for its IRI and values), as Turtle, or as a list of triples; Add to store inserts them, which is handy after previewing an inference rule. ASK answers true or false. Updates (INSERT DATA, DELETE … INSERT … WHERE, CLEAR, DROP, COPY, MOVE, ADD) change the store and report how many triples they added or removed. Examples has a few queries for whichever dataset is loaded. Default graph = union lets patterns outside GRAPH see every named graph too.

Prefixes. ex:Film is short for http://example.org/Film. Add missing prefixes writes the PREFIX lines a query needs from the table in the Prefixes tab, which starts with the usual ones (rdf, rdfs, owl, xsd, foaf, schema, dcterms, skos, the Wikidata set) and learns any @prefix in data you load. The same table shortens IRIs in results and drawings.

Data. Load a sample dataset (replacing the store) or add it to what is there; paste RDF or open a file — Turtle, TriG, N-Triples, N-Quads, JSON-LD, RDF/XML or N3, detected from the file name or the text — into the default graph or a named graph; see each graph’s size, and export the store in any of those formats. Keep my data in this browser saves the store to local storage after every change (up to about 2.5 MB).

Labs. Each lab loads its dataset and has runnable steps with an explanation:

  • Triples and prefixes — patterns, joins, a, DISTINCT, a first CONSTRUCT.

  • OPTIONAL and FILTER — missing values, FILTER NOT EXISTS, BIND, language tags.

  • Property paths — |, /, +, *, ^ and ! over the family tree: descendants, ancestors, siblings, and counting generations.

  • Aggregates — GROUP BY, COUNT, SUM, AVG, GROUP_CONCAT, HAVING and sub-queries.

  • Named graphs — provenance with one graph per profile, GRAPH ?g, FROM, and writing into a graph.

  • RDFS inference by rules — the RDFS entailment rules for subClassOf, subPropertyOf, domain and range written as SPARQL INSERT … WHERE, run round after round until a round adds nothing (a fixpoint), with a count per rule and round.

  • SPARQL next to Cypher — the same questions in both languages, for comparison with the graph database playground.

Wikidata and other endpoints. Set Run on to Wikidata to send the query to https://query.wikidata.org/sparql (there are examples), or to another endpoint by URL. The endpoint must allow cross-origin requests from a web page; Wikidata does. Updates are never sent anywhere.

History keeps the last 100 queries in this browser. Share link carries the query, the dataset, the open lab and the endpoint choice — not your data.

Linking

Hand-written links work too: ?ds=family&q=… (ds is movies, family, solar, foaf or empty), ?lab=paths#labs (triples, optional, paths, aggregates, graphs, inference, cypher), ?on=wikidata&q=…, &view=table|text|json|graph|turtle.

Limits

  • Queries run on the page’s main thread; a query that takes a long time freezes the page until it finishes. The samples answer in a few milliseconds.

  • No LOAD of remote data (the page has no way to fetch arbitrary URLs for the engine), no SERVICE federation, and no reasoning beyond the rules you run — Oxigraph is a plain SPARQL store, which is what makes the rule lab worth doing.

  • The drawing shows up to 150 nodes; very large CONSTRUCT results are better read as Turtle.

  • The film, planet and moon facts are real but rounded and incomplete; the family and the people in the FOAF graph are invented.

Related: Graph database playground (Cypher), Postgres playground, JSON workbench (for JSON-LD as JSON), Code sandbox.

Browser support

Any current browser with WebAssembly and JavaScript modules: Chrome, Edge, Firefox and Safari.

Privacy

Your data and queries stay in the page, except when you choose Run on → Wikidata or another endpoint: then the query text is sent from your browser to that endpoint, and its answer comes back. Oxigraph itself (MIT / Apache-2.0) is downloaded from cdn.jsdelivr.net when the page opens. Settings, prefixes and history are kept in this browser’s local storage.

Runs entirely in your browser — network requests go only to the services named on this page.