Sometimes SPARQL code appears in URLs, as long query strings, and then it is basically a very long one-liner, often URL-encoded. Or the SPARQL contains a lot of UNIONs which have linebreaks located at wrong places.

I am looking for a SPARQL query formatter.

Ideally that would be a VSCode extension. However currently (Dec 2020) there exists no such extension in the VSCode marketplace.

I would also work with a command line tool (for Linux), or an online tool where users can paste in the unformatted query and receive a formatted query.

1 Answer 1


Answering my own question:

Wikidata has a formatter in the Wikidata Query service. I can copy my unformatted query text, paste it in the Wikidata window, and the query will be formatted.

enter image description here

However the "diamond symbol/icon is only enabled and only works if the query is syntactically valid, and if it has no undefined prefixes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.