SPARQL Query Builder - Build and Test SPARQL Queries Online
Online SPARQL query builder tool to build, test, and execute SPARQL queries against RDF data with interactive editor and syntax highlighting.
How to Use SPARQL Query Builder - Step by Step Guide
Write Your SPARQL Query
Start by writing your SPARQL query in the top editor. SPARQL (SPARQL Protocol and RDF Query Language) is the standard query language for RDF data:
Example: Sample SPARQL SELECT Query
Here's a sample SPARQL query to find all people in the dataset:
PREFIX schema: <http://schema.org/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT ?person ?name ?email ?affiliation WHERE { ?person rdf:type schema:Person . ?person schema:name ?name . ?person schema:email ?email . OPTIONAL { ?person schema:affiliation ?affiliation } } ORDER BY ?name
Provide RDF Data
In the bottom editor, paste your RDF data in Turtle format. This is the data that your SPARQL query will search through:
Example: Sample RDF Turtle Data
Here's sample RDF data in Turtle format:
@prefix schema: <http://schema.org/> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . <http://example.org/person/1> rdf:type schema:Person ; schema:name "Dr. Yuki Tanaka" ; schema:email "[email protected]" ; schema:affiliation "MIT" .
Execute Query and View Results
Click the "Execute" button to run your SPARQL query against the RDF data. The results show up on the right as JSON:
Frequently Asked Questions
What is SPARQL and why use it?
SPARQL (SPARQL Protocol and RDF Query Language) is the standard query language for RDF data and semantic web applications. It's similar to SQL but designed for graph-based data, allowing you to query relationships between entities in knowledge graphs, linked data, and ontologies.
What types of SPARQL queries are supported?
SELECT queries built from triple patterns, with PREFIX, OPTIONAL, UNION, nested { } groups, SELECT *, DISTINCT, ORDER BY (numbers sort as numbers) and LIMIT/OFFSET. Patterns that share a variable are joined properly, so every row really matches the whole WHERE clause. FILTER, BIND, VALUES, MINUS, property paths, GROUP BY and aggregates aren't handled yet; if your query uses one, you get a message saying so instead of half-right results. ASK, CONSTRUCT and DESCRIBE aren't supported either.
Can I use this with live SPARQL endpoints?
This tool currently works with local RDF data you provide. For querying live SPARQL endpoints like DBpedia or Wikidata, you can use their web interfaces. This tool is handy for trying out the shape of a query on a small sample before you run it against a real endpoint.
What RDF data formats are accepted?
The tool accepts RDF data in Turtle format (.ttl), which is the most human-readable RDF serialization. You can convert other RDF formats using our RDF Format Converter or export Turtle data from tools like Protégé.
What do the results look like?
Results use the standard SPARQL 1.1 JSON results format: each value is marked as a uri, bnode or literal, and literals keep their language tag (xml:lang) or datatype. Values are copied exactly as they appear in your data, so an ID like 8901240544102066246 or a code like 00501 comes back digit for digit.
How do I learn SPARQL syntax?
Start with the sample query provided and modify it gradually. The W3C SPARQL specification provides comprehensive documentation. Key concepts: PREFIX for namespaces, SELECT for variables (?variable), WHERE for patterns, and OPTIONAL for optional matches.
Is the SPARQL Query Builder free to use?
Yes, it's free and there's nothing to sign up for. The query runs in your browser, so your query and data are never uploaded. Very broad queries that would build more than 200,000 intermediate rows are stopped with a message so the tab doesn't freeze.
Related Tools
JSON to RDF Turtle
Convert JSON to RDF Turtle format for semantic web applications
RDF Turtle to JSON
Convert RDF Turtle format to JSON for easier processing
JSON-LD Validator
Validate JSON-LD syntax and context resolution
RDF Validator
Validate RDF Turtle syntax and structure
JSON-LD to RDF Turtle
Convert JSON-LD to RDF Turtle format for semantic web applications
RDF Format Converter
Convert between RDF formats (Turtle, N-Triples, RDF/XML, JSON-LD)