Query any file with SPARQL
SPARQL Anything reads CSV, JSON, XML, spreadsheets, HTML, Markdown and other formats as RDF. You query them, and build knowledge graphs from them, with plain SPARQL 1.1. There is no mapping language to learn and no conversion step.
Version 1.3.0, released October 2026. Java 21 or later. Apache License 2.0.
id,name,city
1,Ada,London
2,Grace,New York
[ rdf:type fx:Root ;
rdf:_1 [ xyz:id "1" ;
xyz:name "Ada" ;
xyz:city "London" ] ;
rdf:_2 [ xyz:id "2" ;
xyz:name "Grace" ;
xyz:city "New York" ]
] .
CONSTRUCT { ?s ?p ?o } WHERE {
SERVICE <x-sparql-anything:location=people.csv,csv.headers=true> { ?s ?p ?o }
}
{
"people": [
{ "name": "Ada", "born": 1815,
"languages": ["English", "French"] },
{ "name": "Grace", "born": 1906,
"languages": ["English"] }
]
}
[ rdf:type fx:Root ;
xyz:people [
rdf:_1 [ xyz:name "Ada" ;
xyz:born "1815"^^xsd:decimal ;
xyz:languages [ rdf:_1 "English" ;
rdf:_2 "French" ] ] ;
rdf:_2 [ xyz:name "Grace" ;
xyz:born "1906"^^xsd:decimal ;
xyz:languages [ rdf:_1 "English" ] ]
]
] .
CONSTRUCT { ?s ?p ?o } WHERE {
SERVICE <x-sparql-anything:location=people.json> { ?s ?p ?o }
}
<people xml:lang="en">
<person id="1">Ada</person>
<person id="2">Grace</person>
</people>
[ rdf:type fx:Root , xyz:people ;
xml:lang "en" ;
rdf:_1 [ rdf:type xyz:person ;
xyz:id "1"@en ;
rdf:_1 "Ada"@en ] ;
rdf:_2 [ rdf:type xyz:person ;
xyz:id "2"@en ;
rdf:_1 "Grace"@en ]
] .
CONSTRUCT { ?s ?p ?o } WHERE {
SERVICE <x-sparql-anything:location=people.xml> { ?s ?p ?o }
}
xml:lang tag. Each file becomes a Façade-X graph of containers, slots and values, which you then reshape with SPARQL.What's new
- SPARQL Anything v1.3.0 released, following Façade-X specification 0.1. Note: the root type is now fx:Root.
- Façade-X specification 0.1 released by the W3C Data Façades Community Group.
- Towards a Theory of Façade-X Data Access published in Transactions on Graph Data and Knowledge.
- SPARQL Anything v1.2.0 released.
- First steps of the Data Façades Community Group.
- The W3C Data Façades Community Group opens for participation.
Get started
You need Java 21 or later. This turns a CSV file into schema.org triples.
-
Download the command-line tool
curl -L -O https://github.com/SPARQL-Anything/sparql.anything/releases/download/v1.3.0/sparql-anything-v1.3.0.jarOr pick a jar from the release page. The
-geosparqlvariants add GeoSPARQL support. -
Write a query
Save this as
query.rq, next to thepeople.csvfile from the example above. Options go onfxe:properties, or in theSERVICEIRI as in the example at the top of the page.PREFIX fxe: <http://sparql.xyz/facade-x/engine/> PREFIX xyz: <http://sparql.xyz/facade-x/data/> PREFIX schema: <https://schema.org/> CONSTRUCT { ?person a schema:Person ; schema:name ?name ; schema:homeLocation ?city . } WHERE { SERVICE <x-sparql-anything:> { fxe:properties fxe:location "people.csv" ; fxe:csv.headers true . ?row xyz:id ?id ; xyz:name ?name ; xyz:city ?city . } BIND (IRI(CONCAT("http://example.org/person/", ?id)) AS ?person) } -
Run it
java -jar sparql-anything-v1.3.0.jar -q query.rq<http://example.org/person/1> a schema:Person ; schema:homeLocation "London" ; schema:name "Ada" . <http://example.org/person/2> a schema:Person ; schema:homeLocation "New York" ; schema:name "Grace" .Use
-fto pick another output format, such asntorjsonld, and-oto write to a file. See the command-line reference.
From Python
pip install pysparql-anything
import pysparql_anything as sa
engine = sa.SparqlAnything()
engine.run(query="query.rq", format="ttl")
The jar is downloaded on first use. See PySPARQL Anything.
As a SPARQL endpoint
java -jar sparql-anything-server-v1.3.0.jar
Starts a Fuseki server at http://localhost:3000/sparql. Any SPARQL client can send it queries that use SERVICE <x-sparql-anything:…>.
From Java
Use the engine as a library inside Apache Jena. See the Java client example and the documentation.
How Façade-X works
Façade-X is the model SPARQL Anything uses to present every format in the same shape. It uses a small subset of RDF and no domain vocabulary, so the source content appears as it is. Your query then maps it to the ontology you need.
- Containers
- Each structure in the source becomes a container, a blank node: a table and its rows, a JSON object or array, an XML element. The outermost one is typed
fx:Root. - Slots
- Containers hold slots. Named parts, such as column headers, object keys and attributes, become properties in the
xyz:namespace. Ordered parts, such as rows, array items and child nodes, becomerdf:_1,rdf:_2and so on. - Values
- The content at the leaves becomes RDF literals, keeping the text as it appears in the source. Where the format says what a value is, it gets a datatype or a language tag: a JSON number becomes
"1815"^^xsd:decimal, XML text underxml:lang="en"becomes"Ada"@en. - Types
- Where the source gives a structure a name, such as an XML element or an HTML tag, the container gets that name as an
rdf:type.
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fxe: <http://sparql.xyz/facade-x/engine/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
The Façade-X primer walks through the model with examples. The metamodel specification defines it formally, and the format mappings say how each format is represented.
Features
Querying
- Plain SPARQL 1.1. Point a
SERVICE <x-sparql-anything:…>clause at a resource and set options in the IRI or withfxe:properties. - Build knowledge graphs with
CONSTRUCT, or get tables withSELECT. Output RDF, RDF-star or tabular results. - Output follows the Façade-X specification 0.1, including datatypes for JSON numbers and language tags from
xml:lang. - Join data from several sources in one query by combining
SERVICEclauses. - A function library for container slots, strings, hashes and building entity IRIs.
- Query templates: run a query once for each row of a SPARQL result set file, or for values given on the command line.
Reaching data
- Read a file or URL, inline content, or the output of an external command.
- Call Web APIs with a full HTTP client: any method, custom headers, authentication.
- Query files inside Zip and Tar archives, and list the contents of folders.
- Read from Amazon S3 buckets.
Large files
- Slicing evaluates the query on one row, array item or element at a time, for CSV, JSON and XML.
- An on-disk mode keeps the Façade-X graph in Apache Jena TDB2 instead of memory.
- The command line can stream
CONSTRUCToutput triple by triple.
Running it
- Command-line tool and a Fuseki-based SPARQL server.
- Java library, built on Apache Jena ARQ.
- Python library with results as RDFLib graphs, pandas data frames or NetworkX graphs.
Supported formats
- CSV and TSV
- JSON
- XML
- HTML
- Spreadsheets (XLS, XLSX)
- Word documents (DOCX)
- Slides (PPTX)
- Markdown
- YAML
- BibTeX
- Plain text
- RDF
- Zip, Tar and folders
- Binary files
Image metadata (EXIF) is also supported. You can add formats through the extension mechanism.
Tutorials and showcases
Worked examples on real data. The full reference is in the documentation, with more examples on the tutorials page.
-
A gentle introduction to SPARQL Anything
The Façade-X model, with basic transformations of JSON, CSV and XML. Video.
-
Open data from the Tate Gallery
Uses the fx:anySlot function and chains several SERVICE clauses. Runs on the command line.
-
Artists and artworks from the IMMA museum website
Builds a knowledge graph from HTML pages, with parametrised queries that take SPARQL result sets as input.
-
The Propbank dataset
An advanced XML transformation, including querying files inside a Zip archive.
-
YAML annotations in Markdown headers
Chains transformations: Markdown files, then their YAML front matter, then the annotations it contains.
-
A music ontology from MusicXML files
Derives note sequences, computes n-grams and populates a music notation ontology.
Façade-X as a W3C specification
The W3C Data Façades Community Group is writing Façade-X up as an open specification, so that other engines can implement the same model and give the same answers. SPARQL Anything is the reference implementation.
Release 0.1 of the specification was published on 6 October 2026. Anyone can join the group, comment on the drafts or contribute test cases.
Documents
- Primer
- Concepts and metamodel
- Schema vocabulary (
fx:) - Engine vocabulary (
fxe:) - Data access in SPARQL
- Format mappings: CSV, JSON, XML
Group work
From version 1.3.0, SPARQL Anything follows release 0.1. The root container is typed fx:Root: queries that match fx:root need updating. Engine options use the Engine vocabulary (fxe:properties fxe:location …); the fx: option forms still work but are deprecated.
Publications
If you use SPARQL Anything in your work, please cite the ACM TOIT article. Cite the TGDK article for the formal account of Façade-X data access.
Reference publications
-
Knowledge graph construction with a façade: a unified method to access heterogeneous data sources on the web
BibTeX
@article{asprino2023knowledge, title={Knowledge graph construction with a fa{\c{c}}ade: a unified method to access heterogeneous data sources on the web}, author={Asprino, Luigi and Daga, Enrico and Gangemi, Aldo and Mulholland, Paul}, journal={ACM Transactions on Internet Technology}, volume={23}, number={1}, pages={1--31}, year={2023}, publisher={ACM New York, NY}, doi={10.1145/3555312} } -
Towards a Theory of Façade-X Data Access: Satisfiability of SPARQL Basic Graph Patterns
BibTeX
@article{asprino2026tgdk, author={Asprino, Luigi and Daga, Enrico}, title={{Towards a Theory of Fa{\c{c}}ade-X Data Access: Satisfiability of SPARQL Basic Graph Patterns}}, journal={Transactions on Graph Data and Knowledge}, volume={4}, number={2}, pages={5:1--5:46}, year={2026}, publisher={Schloss Dagstuhl -- Leibniz-Zentrum f{\"u}r Informatik}, doi={10.4230/TGDK.4.2.5} } -
Facade-X: an opinionated approach to SPARQL Anything
BibTeX
@article{daga2021facade, title={Facade-X: an opinionated approach to SPARQL Anything}, author={Daga, Enrico and Asprino, Luigi and Mulholland, Paul and Gangemi, Aldo}, journal={Studies on the Semantic Web}, volume={53}, pages={58--73}, year={2021}, publisher={IOS Press} }
Other publications
-
PySPARQL Anything Showcase
BibTeX
@inproceedings{ratta2024demo, title={PySPARQL Anything Showcase}, author={Ratta, Marco and Daga, Enrico and Asprino, Luigi}, booktitle={ESWC 2024 Posters and Demos}, year={2024} } -
Streamlining Knowledge Graph Construction with a façade: The SPARQL Anything project
BibTeX
@inproceedings{asprino2023streamlining, title={Streamlining Knowledge Graph Construction with a fa{\c{c}}ade: The SPARQL Anything project}, author={Asprino, Luigi and Daga, Enrico and Dowdy, Justin and Mulholland, Paul and Gangemi, Aldo and Ratta, Marco}, booktitle={ENDORSE: The European Data Conference on Reference Data and Semantics}, year={2023}, publisher={Publications Office of the European Union} } -
Knowledge Graph Construction from MusicXML: an empirical investigation with SPARQL Anything
BibTeX
@inproceedings{ratta2022knowledge, title={Knowledge Graph Construction from MusicXML: an empirical investigation with SPARQL Anything}, author={Ratta, Marco and Daga, Enrico}, booktitle={Musical Heritage Knowledge Graphs Workshop (MHKG) at ISWC 2022}, year={2022}, doi={10.5281/zenodo.7261671} }