Loading SPARQL Query Builder...
Please wait a moment

How to Use SPARQL Query Builder - Step by Step Guide

Step 1

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:

•
Write directly: Type your SPARQL SELECT query in the query editor
•
Upload a file: Click "Upload" to load a .sparql or .rq query file
•
Try the sample: Click "Sample" to load example query and 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
Step 2

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:

•
Paste RDF data: Turtle with @prefix declarations and triples; every prefix you use has to be declared
•
Use sample data: Click "Sample" to load both query and matching data
•
Import from sources: Export data from triple stores like Apache Jena

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" .
Step 3

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:

•
Execute query: Click the green "Execute" button to run the query
•
View results: Results shown in standard SPARQL JSON results format
•
Copy or download: Save results as JSON for further processing

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.