
Turtle RDF Language Server for VS Code
Language support for RDF Turtle (.ttl), TriG (.trig), N-Triples (.nt),
N-Quads (.nq) and SPARQL (.rq, .sparql, .ru): ontologies (OWL, RDFS,
SKOS), SHACL shapes, linked data, and the queries and updates you run on them. Powered
by turtle-lsp, a language
server written in Rust. After a keystroke in a 30,000-line file, fresh
diagnostics arrive in about 5 ms.
Try it first in your browser, with nothing to install: RDF Editor.

Passes the W3C test suites: Turtle, TriG, N-Triples and N-Quads 1137/1137,
SPARQL 1.1 and 1.2 syntax 425/426, SHACL Core 98/98, SHACL-SPARQL 23/23.
Reasoning
TurbOWL, an OWL 2 RL reasoner,
reasons over your workspace in the background. It is on by default.
- Hover on a resource lists its inferred types. Each has a proof with one W3C rule per step, and each triple in the proof links to its line.
- With
turtle.reasoning.diagnostics on, contradictions such as a member of two disjoint classes show as diagnostics.
- ▶ Run query can also match inferred triples. Set
turtle.query.reasoning to default or complete, or pick a rule set in the results panel's Inferred choice.

Features
Syntax highlighting for Turtle, TriG, N-Triples, N-Quads, SPARQL and RDF 1.2 (triple terms <<( )>>, reifiers ~, annotations {| |}), plus semantic highlighting of classes, properties, individuals, datatypes and deprecated terms.
Error checking as you type: syntax errors with recovery (one mistake does not hide the rest of the file), undeclared, unused and duplicate prefixes, invalid IRIs and language tags.
Vocabulary checks: unknown or deprecated terms in 80+ well-known vocabularies (rdf, rdfs, owl, skos, sh, dcterms, foaf, schema.org, prov, sosa, qudt and more), with "did you mean" fixes. Matched by namespace IRI, so your own ex: or sd: prefixes are never checked against the wrong vocabulary. Terms in your own namespaces that nothing describes (often typos) are flagged too.
SHACL validation: data is checked against the shapes in your workspace about a second after you stop typing, and on save. SHACL Core and SHACL-SPARQL (sh:sparql constraints, SPARQL targets and components). SPARQL inside shapes is checked as you type, and mistakes in the shapes themselves are flagged.
Reasoning with TurbOWL, on by default (turtle.reasoning.rules). See Reasoning above.
owl:imports: imported ontologies are resolved from the workspace, a catalog-v001.xml or the cache (Turtle, N-Triples, RDF/XML, OWL Functional syntax, OWL/XML), so their terms complete, hover and validate. An unresolved web import has a quick fix that fetches that one import and caches it; go to definition opens the cached copy.
Completion of prefixes and terms; type Pers to get foaf:Person. Classes come first after a, properties in predicate position; properties your SHACL shapes require or whose rdfs:domain fits come first, and sh:in values are offered. Accepting a term adds its @prefix line for you.
Hover with label, comment, types and where a resource is described; label inlay hints for opaque IRIs.
Navigation: go to definition, type definition (a resource's class), implementations (a class's instances and subclasses), type hierarchy, find references, document highlight.
Rename across files, including a prefix shared through prefixes.ttl, which is renamed in every file that takes it from there.
Formatting that keeps comments and statement order and never changes the graph.
Outline, workspace symbol search and folding.
Workspace graph: "Turtle: Show Workspace Graph" (or the graph button in the title bar of an RDF file) draws the workspace as one graph, with filters, search, a focus view and a class tree; click a node to go to its definition.
Quick fixes and refactorings: add a missing prefix (or the owl:imports that defines it), add all missing prefixes, remove an unused prefix, fix a misspelled term, organise prefixes, shorten or expand an IRI, extract a prefix for a namespace.
SPARQL
SPARQL queries and updates (SPARQL 1.1 and 1.2) get the same knowledge of your
workspace and the vocabularies:
- Syntax errors as you type, at the token where the query stops making sense; undeclared, unused and duplicate prefixes; unknown or deprecated vocabulary terms and undescribed terms of your own, with "did you mean"; a projected variable that the
WHERE clause never binds.
- Completion of keywords, variables, prefixes, terms and built-in functions. Accepting a term adds its
PREFIX line.
- Hover and label inlay hints on terms, as in Turtle.
- Go to definition, references and document highlight for terms, prefixes and variables.
- Rename of variables, prefixes and terms. Renaming a term in a Turtle file also renames it in your queries, and the other way round.
- Formatting that keeps comments and never changes what the query means.
- Quick fixes: add a missing
PREFIX (or all of them), remove an unused one, fix a misspelled term; organise prefixes, shorten or expand an IRI.
- Semantic highlighting, folding and an outline of the query or update operations.
▶ Run query above a query runs it over your workspace's files as the editor has them, unsaved edits included, and shows the results in a Query Results panel beside it: a table you can sort, copy or export as CSV or JSON (or true/false for ASK, triples for CONSTRUCT). Its Inferred choice (Off, Default rules or Complete rules; it starts at turtle.query.reasoning) reruns the query with or without what TurbOWL infers, and the results say how many inferred triples they include. The query runs in the background with a time limit and a row limit. No endpoint is contacted, and updates are never run.

N-Quads
.nq files get what N-Triples files get: syntax errors per line with recovery, hover, navigation, an outline grouped by graph, and formatting with one quad per line. Their quads join the workspace, so terms described in a dataset dump count as described in your Turtle files.
JSON-LD
.jsonld files keep VS Code's JSON highlighting and get the server's checks: JSON syntax errors, @context errors, keys the context does not define, invalid IRIs and language tags, and SHACL results from your shapes on the key or value that breaks them. A compact IRI such as rdfs:label whose prefix the @context lacks gets a warning and a quick fix that adds the prefix.
Editing works as in Turtle:
- completion in keys and
@type values from the context in force, including @vocab terms and prefix:local names; completing a known prefix the context lacks adds it to the @context;
- hover, go to definition (into the
@context entry or a context file), references and highlights on terms;
- rename of terms, keyword aliases and IRIs, each use rewritten in its own form; unsafe renames are refused with the reason;
- Format Document, keeping the same JSON value;
- semantic highlighting of keywords, properties and classes, and an outline that nests named graphs.
Their terms count in your Turtle and SPARQL files. Common contexts (schema.org, ActivityStreams, Verifiable Credentials, DID) are bundled; other remote contexts are fetched only with turtle.imports.network on.
RDF/XML (.owl, .rdf)
.owl and .rdf files are read as part of the workspace: their triples count in your Turtle and SPARQL files, in Run query, SHACL validation, reasoning and the workspace graph, and an owl:imports of one needs no catalog. The file's content decides its syntax: RDF/XML, or Turtle or JSON-LD under that name. They keep VS Code's XML language, and the extension attaches to them: hover, go to definition, find references, the outline, folding and the file's problems (broken XML, a syntax the server cannot read, SHACL results) work inside them. Rename works there too: renaming an IRI in any file edits the .owl and .rdf files that use it, each use in its own form, and VS Code shows those edits in the refactor preview for you to confirm. When a use cannot be rewritten exactly (one read from an entity, a character reference, vocabulary the syntax implies, a new namespace with no prefix there, a file with a syntax error), the whole rename is refused, with the file, line and reason. turtle.rename.rdfXml turns this off; it does not cover a .owl or .rdf whose text is OWL Functional syntax or OWL/XML, which is renamed as below. Completion (Ctrl+Space) works in them, even in a file half typed: after <, rdf:Description and the classes where a node goes, the properties where a property goes, each as a qualified name; in rdf:about, rdf:resource and rdf:datatype, the subjects, the IRIs the property takes and the datatypes, as full IRIs. A term of a well-known vocabulary whose namespace has no prefix in the file adds its xmlns:p to the root element. VS Code's XML language does not suggest inside attribute values while you type: press Ctrl+Space there. Formatting and quick fixes are never offered in .owl and .rdf files, and VS Code does not list the extension as an XML formatter. This includes a .owl that holds Turtle: it is read as Turtle and gets Turtle's completion, but the editor does not format it (turtle-lsp format onto.owl on the command line does). With turtle.diagnostics.workspace on (always in the browser), the problems of the ones that are not open appear in the Problems panel too.
A .owl or .rdf file opened on its own, with no folder, does not start the extension: open its folder instead.
OWL Functional syntax (.ofn)
.ofn files get the language "OWL Functional Syntax", with its highlighting, and a .owl whose text is OWL Functional syntax (as ROBOT and Protégé write OBO edit files) is read as that syntax too. Their axioms are read as RDF, as an RDF/XML file's are: their classes and properties count in other files (hover with their labels, completion, no unknown-term), go to definition opens a term's Declaration, and find references, highlights, the outline, workspace symbols and folding work in them, as do queries, SHACL validation and reasoning. Each error is in the Problems panel at its exact place, with the code ofn-syntax: what the parser expected, an undeclared prefix, an IRI that is not absolute, too few operands, a cardinality that is not a non-negative integer; an axiom with an error is left out, the rest is read. Completion (Ctrl+Space) offers what the grammar takes at the cursor, even in an axiom not yet closed: the axiom keywords, the expressions and the terms of the slot's kind (classes where a class expression goes, properties, datatypes, individuals), each keyword with its operands as a snippet; after prefix:, that namespace's terms, and a term whose prefix the file does not declare adds its Prefix(…) line. Rename works in them too: renaming an IRI in any file edits the .ofn files that use it, and a rename can start in one. Each use keeps its form: <…> stays a full IRI, and ex:A keeps its prefix, or takes another declared one (rdf:, rdfs:, xsd: and owl: count as declared), else becomes <…>. When a use cannot be rewritten (the new name would break the file or change its graph, an IRI the OWL mapping implies with no text of its own, a file with a syntax error), the whole rename is refused, with the file, line and reason. Formatting and quick fixes are never offered in them. A Functional .owl keeps the XML language and gets the same completion.
OWL/XML (.owx)
.owx files, and a .owl or .rdf whose text is OWL/XML (as Protégé and ROBOT can save it), are read as OWL/XML, as OWL Functional syntax is, and only completion and rename edit them: their axioms are read as RDF, so their classes and properties count in other files, and hover, go to definition, find references, highlights, the outline, workspace symbols and folding work in them, as do queries, SHACL validation and reasoning. Each error is in the Problems panel at its exact place: xml-syntax for the XML, owx-syntax for the rest (an unknown element or attribute, an undeclared prefix, an IRI that is not absolute, too few operands); an axiom with an error is left out, the rest is read. Completion (Ctrl+Space) offers, after <, the elements the schema takes there (an entity's element written whole, <Class IRI="…"/>, any other with its end tag), and in IRI, datatypeIRI and abbreviatedIRI values the terms of the element's kind (classes in <Class>); a term of a well-known prefix the file does not declare adds its <Prefix> element. As in .owl files, press Ctrl+Space inside an attribute value. Rename works in them as in .ofn files, on an IRI or abbreviatedIRI value or an <IRI> or <AbbreviatedIRI> text: each use keeps its form, a relative IRI value stays relative to its xml:base when it can, and an abbreviatedIRI with no declared prefix for the new IRI becomes IRI="…" (an <AbbreviatedIRI> element refuses instead). A use written with an entity or character reference refuses the rename too. Formatting and quick fixes are never offered in them.
They open in VS Code's XML language, with its highlighting. VS Code's XML language does not list .owx, so the extension sets "files.associations": { "*.owx": "xml" } as a default; your own files.associations entry for *.owx replaces it. A .owx file that starts with <?xml opens as XML either way. As with .owl, a .owx file opened on its own, with no folder, does not start the extension.
Project prefixes
If your Turtle files share a prefix header instead of declaring prefixes
themselves, put the header in a prefixes.ttl. Every Turtle file and SPARQL
query in that folder or below can then use those prefixes. Or set
turtle.prefixes.
Settings
turtle.prefixes: prefixes available in every file, e.g. { "ex": "http://example.org/" }.
turtle.server.path: use a different turtle-lsp binary: an absolute path to a file that exists (user settings only; in an untrusted workspace a binary inside the workspace is never run).
turtle.trace.server: log the language server traffic to the Output panel.
turtle.inlayHints.labels: show labels as inlay hints for opaque IRIs (default), all terms, or off.
turtle.shacl.enabled, turtle.shacl.maxTriples: SHACL validation, and the most triples one run validates, the shared triples and every dataset together; above it validation is skipped (default 2,000,000 triples).
turtle.shacl.onType: also validate while typing, not only on save (default on).
turtle.reasoning.rules: reason with TurbOWL, an OWL 2 RL reasoner: off, default (TurbOWL's default rules; the default) or complete (every W3C OWL 2 RL rule; slower). Hover then lists a resource's inferred types with their proofs.
turtle.reasoning.diagnostics: show TurbOWL's findings, such as a member of two disjoint classes, as diagnostics with their proofs (default off: a project's SHACL shapes often check the same rules).
turtle.reasoning.maxTriples: the most triples one reasoning run reads, the workspace's and its imports'; above it reasoning is skipped, with a note (default 2,000,000 triples).
turtle.lint.undescribedTerms: warn about your own terms that are described nowhere in the workspace.
turtle.lint.ignore: diagnostic codes never to report, such as unused-prefix or duplicate-label. Adds to the project's lint.ignore in turtle-lsp.json.
turtle.lint.enable: off-by-default checks to switch on: missing-label, missing-definition, multiple-definitions, duplicate-definition, lowercase-definition, missing-ontology-title, missing-ontology-description, missing-ontology-license. Adds to the project's lint.enable; a code in either lint.ignore stays off.
turtle.imports.network: fetch owl:imports and JSON-LD contexts over the network (default off; off in untrusted workspaces). With it off, the quick fix on an unresolved import fetches that one import and caches it. Fetches go only to public addresses, follow at most 10 redirects (never from https to http), and one pass makes at most 100 requests; see Network access.
turtle.imports.unresolved: while an import can't be loaded, SHACL results it could change are warnings with a note (soften, the default); ignore keeps their full severity.
turtle.format.lineWidth: line width for formatting (default 100).
turtle.codeLens.references: show "N references" above each subject a file describes; click it to list them (default on).
turtle.diagnostics.workspace: also check the files that are not open, in the background, and show their problems (default off).
turtle.parse.incremental: after an edit, parse only the statements around it, not the whole file (default on). The results are the same either way; if a file you edit shows other problems than after reopening it, turn this off and please report the file.
turtle.rename.rdfXml: a rename edits the RDF/XML files (.owl, .rdf) that use the IRI too, and can start in one (default on). Off, a rename that would edit one is refused. OWL Functional and OWL/XML files are always renamed.
turtle.query.timeoutSeconds, turtle.query.maxRows: stop a query run with ▶ Run query after this many seconds (default 30), and show at most this many rows of its results (default 1000); 0 for no limit.
turtle.query.reasoning: run ▶ Run query over what TurbOWL infers too: off (default), default or complete. The Inferred choice in the results panel starts at this value and reruns the query with another.
turtle.query.maxBufferedRows: stop a query that keeps more than this many rows in memory to sort, group, deduplicate or join them (default 10 000 000; 0 for no limit). It counts rows, not bytes: ordinary rows take about 100 bytes each, long text values take more.
The extension sends the server only the settings you set. A setting you leave unset comes from the project's turtle-lsp.json, or takes its default. That file cannot turn on turtle.imports.network or raise the query, SHACL and reasoning limits; only your own settings can. In an untrusted workspace, turtle.server.path, turtle.imports.network, turtle.query.*, turtle.shacl.maxTriples, turtle.reasoning.maxTriples and turtle.diagnostics.workspace take your user settings only.
VS Code completes and checks turtle-lsp.json against the extension's JSON schema: each key with its default, its choices and its description, and a warning on a misspelt key, a wrong value, or a limit the file cannot raise.
In the browser (vscode.dev, github.dev)
The extension also runs in VS Code for the Web. Press . on a GitHub
repository, or open a folder in vscode.dev, and the server runs inside the
browser tab, compiled to WebAssembly. Your files are not uploaded anywhere.
What works: the language features above for every file type; cross-file
features over the repository's RDF and SPARQL files (definitions,
references, rename, completion of terms declared in other files, and
problems in files you have not opened); prefixes.ttl; a turtle-lsp.json
at the root of the first folder; SHACL validation; the workspace graph.
What does not work:
- ▶ Run query is not shown, as it writes its results to disk.
owl:imports are not fetched from the web, so the terms of a web import stay unknown, as when you are offline.
- The extension reads at most 2,000 files and 50 MB of RDF. Past either limit it says how many files it read; the rest are not checked or found by references.
- A folder you add to the workspace after the start is read only after Turtle: Restart Language Server.
Your turtle.* settings apply, except turtle.server.path.
Also for Neovim and other editors
The same server works in any editor that speaks the Language Server Protocol.
See the project README
for Neovim setup.
| |