SPARQL Playground (RDF Playground)

About the tool

This interactive tool allows you to experiment with running SPARQL queries against RDF datasets. You can use SPARQL federation to effectively join in the data from external SPARQL endpoints.

Despite it using Python-based RDFLib for its core functionality, this tool runs entirely in the browser thanks to Pyodide.


The RDF dataset to query.
The SPARQL query to execute.
Press the Run query button to execute the query.

What are SPARQL and RDF?

The Resource Description Framework (RDF) is a format for structured data that uses triples to represent information. A set of RDF triples, a.k.a. an RDF dataset, can be stored in a database or file and queried using the SPARQL query language (similar to how SQL works for relational databases).

What is SPARQL federation?

Federation is one of the key features of SPARQL that allows you to extend your queries to external data sources on the web and combine the results with your local data. This is done using the SERVICE keyword in SPARQL queries.

Here's a simple example of a federated query that retrieves additional data from an external endpoint:

PREFIX ex: <>
PREFIX foaf: <>

SELECT ?friend ?friendOfFriend
ex:Alice foaf:knows ?friend .

?friend foaf:knows ?friendOfFriend .


I believe that there is a lot of untapped potential in RDF/SPARQL and RDF-based knowledge graphs to solve complex data problems, so I built this as an interative demo/showcase for the power and elegance of these technologies. With this online playground, it is super easy to run one-off, ad-hoc, experimental SPARQL queries, and this is what I think makes the tool special.

In addition to being a playground, this tool can also be used to learn about RDF and SPARQL or to troubleshoot production queries. My focus will remain on making this tool as simple and engaging as possible, and I'm open to feedback and suggestions for improvements.

How does it work?

This tool is built on top of RDFLib, a Python library that provides a simple way to manipulate and query RDF using SPARQL. I'm also using Pyodide to move the entire tool to the browser to remove server-side dependencies and simplify the deployment process. I had to slightly customize RDFLib to make it work with browser-initiated network requests to SERVICE endpoints since Pyodide does not support the urllib.request.urlopen method.

Executing SPARQL queries on the client also means that the SERVICE queries can be blocked if the external SPARQL endpoint does not support CORS (Cross-Origin Resource Sharing). I might add a toggle to use a proxy server to forward these requests in the future.

I've also looked into using JavaScript libraries (e.g. rdflib.js) for the RDF/SPARQL logic. They are all very powerful but don't currently support SPARQL federation.

Related projects

SPARQL is a query language for graph data. The graph model of thinking fits well a lot of use cases.
SPARQL federation is an incredibly useful feature for querying distributed RDF graphs.
An overview of the official Nobel Prize Linked Data dataset with some example SPARQL queries.
Edit Turtle documents online.
Turtle, RDF
Query SPARQL endpoints online.
Author and visualize RDF-based knowledge graphs.
RDF, knowledge graphs, data visualization
Query FHIR data using SPARQL.
Provisioning a graph database cluster in AWS using TypeScript.
Look up entities on the Semantic Web.
Semantic Web, Linked Data, RDF
An outline of the structure of the Gene Ontology RDF graph and ways to query it.
bioinformatics, RDF
An overview of the available RDF datasets and discovery tools for COVID-19.
linked data, RDF
A converter for FHIR resources between different formats.

Made by Anton Vasetenkov.

If you want to say hi, you can reach me on LinkedIn or via email. If you like my work, you can support me by buying me a coffee.