Most knowledge graph projects start with an OWL ontology — it defines the classes, properties, and relationships in your domain. But OWL alone doesn't validate data. You need SHACL shapes to enforce constraints.
Writing SHACL shapes by hand is tedious and error-prone. Every class needs a shape. Every property needs constraints. And when the ontology changes, the shapes must change too.
RDF Studio's OWL-to-SHACL translator solves this by automatically generating SHACL shapes from your OWL ontology. It reads your class hierarchy, property definitions, domain/range declarations, and cardinality restrictions — then produces a complete set of SHACL shapes ready for validation.
The translator maps OWL constructs to their SHACL equivalents:
owl:Class
sh:NodeShape
sh:targetClass
nwo:Employee
nws:EmployeeShape
rdfs:domain
sh:property
nwo:firstName domain Employee
rdfs:range
sh:datatype
range xsd:string
sh:datatype xsd:string
sh:class
range nwo:Employee
sh:class nwo:Employee
owl:FunctionalProperty
sh:maxCount 1
owl:minCardinality
sh:minCount
owl:maxCardinality
sh:maxCount
owl:exactCardinality
rdfs:comment
sh:description
rdfs:subClassOf
xsd:pattern
sh:pattern
The translator finds all owl:Class instances in the ontology and creates a sh:NodeShape for each:
# OWL input nwo:Customer a owl:Class ; rdfs:label "Customer" ; rdfs:subClassOf nwo:Organization . # SHACL output nws:CustomerShape a sh:NodeShape ; sh:targetClass nwo:Customer ; rdfs:label "Customer" .
For each property, the translator checks rdfs:domain to determine which class shape owns it:
# OWL input nwo:companyName a owl:DatatypeProperty ; rdfs:domain nwo:Organization ; rdfs:range xsd:string ; rdfs:comment "The name of the organization" . # SHACL output (on OrganizationShape) sh:property [ sh:path nwo:companyName ; sh:datatype xsd:string ; sh:description "The name of the organization" ; sh:nodeKind sh:Literal ; ] .
Note two important mappings:
sh:nodeKind sh:Literal
OWL cardinality restrictions (via owl:Restriction) become SHACL count constraints:
owl:Restriction
# OWL input — Employee must have exactly one firstName nwo:Employee rdfs:subClassOf [ a owl:Restriction ; owl:onProperty nwo:firstName ; owl:cardinality 1 ] . # SHACL output sh:property [ sh:path nwo:firstName ; sh:datatype xsd:string ; sh:minCount 1 ; sh:maxCount 1 ; ] .
Functional properties (owl:FunctionalProperty) are treated as sh:maxCount 1:
# OWL input nwo:birthDate a owl:DatatypeProperty, owl:FunctionalProperty ; rdfs:domain nwo:Employee ; rdfs:range xsd:date . # SHACL output sh:property [ sh:path nwo:birthDate ; sh:datatype xsd:date ; sh:maxCount 1 ; sh:nodeKind sh:Literal ; ] .
When a property has multiple domains via owl:unionOf, the translator creates a property shape on each domain class:
owl:unionOf
# OWL input — companyName belongs to multiple classes nwo:companyName rdfs:domain [ owl:unionOf (nwo:Customer nwo:Supplier nwo:Shipper) ] . # SHACL output — property appears on ALL three shapes nws:CustomerShape sh:property [ sh:path nwo:companyName ; ... ] . nws:SupplierShape sh:property [ sh:path nwo:companyName ; ... ] . nws:ShipperShape sh:property [ sh:path nwo:companyName ; ... ] .
This is how the Northwind ontology shares companyName, contactName, phone, and address across Customer, Supplier, and Shipper — using owl:unionOf instead of inheritance. Both patterns work; the translator handles both.
companyName
contactName
phone
address
Properties defined on a superclass are copied down to every subclass shape. See the dedicated "Inheritance Flattening" article for details.
If sh:closed mode is enabled (on by default), each shape gets:
sh:closed
nws:EmployeeShape a sh:NodeShape ; sh:closed true ; sh:ignoredProperties ( rdf:type ) ; ...
This rejects any property not explicitly listed in the shape. See the "Closed Shapes" article for when to use this.
Properties are assigned sh:order values based on their declaration order in the ontology. This controls display ordering in the SHACL UI:
sh:order
sh:property [ sh:path nwo:firstName ; sh:order 0 ; ... ] ; sh:property [ sh:path nwo:lastName ; sh:order 1 ; ... ] .
If the ontology uses xsd:pattern facets on datatype restrictions, they become sh:pattern:
# OWL input — postalCode must match a pattern owl:onProperty nwo:postalCode ; owl:allValuesFrom [ a rdfs:Datatype ; owl:onDatatype xsd:string ; owl:withRestrictions ( [ xsd:pattern "^[0-9]{5} RDF Studio – SPARQL Editor, Ontology Manager & Knowledge Graph Explorer RDF Studio is a free semantic web IDE and training platform for browsing, querying, and editing RDF knowledge graphs. Home of the Northwind RDF use case with 80+ executable SPARQL competency questions (use case stories) and query templates. Key Features Northwind RDF Use Case – A curated training dataset with full OWL ontology, sample data, and 80+ executable SPARQL competency questions with business use case stories following EKGF methodology. Query Library – 80+ categorized queries spanning data exploration, CRUD operations, OWL axioms, taxonomy navigation, federated queries, and graph analytics — each with descriptions and use case context. Query Templates – Reusable SPARQL patterns for basic exploration, data quality checks, and graph analytics that work across any dataset. SPARQL Editor – Full SPARQL 1.1 query editor with syntax highlighting, autocomplete, PREFIX folding, query library, and execution history. Visual Ontology Editor – Create and edit OWL/RDFS classes, properties, and restrictions in an interactive graph editor with draft workflow and layout persistence. SHACL Shapes Editor & Validator – Browse, edit, auto-generate, and validate SHACL shapes with a validation dashboard and maturity scoring. Knowledge Graph Visualization – Interactive graph visualization with multiple layout engines, node expansion, search, and export. Faceted Search – Auto-generated faceted search interfaces from RDF/OWL ontologies with filters, sorting, and pagination. Traversal Query Builder – Cross-class query builder for navigating complex knowledge graph relationships. Taxonomy & Vocabulary Management – SKOS taxonomy browser, vocabulary import (FOAF, Dublin Core, RDFS), and hierarchical tree editing. Multi-Database Support – Connect to external SPARQL endpoints (GraphDB, Virtuoso, Stardog, Neptune, Fuseki). RDF Instance CRUD – Create, read, update, and delete RDF instances with SHACL validation and named graph targeting. Ontology Maturity Scoring – 5-dimension assessment of ontology quality with schema-data drift detection. Supported Standards RDF, RDFS, OWL, OWL 2, SPARQL 1.1, SHACL, SKOS, Turtle, N-Triples, JSON-LD, Dublin Core, FOAF, Schema.org Supported Triple Stores Oxigraph, GraphDB, Virtuoso, Stardog, Amazon Neptune, Apache Jena Fuseki, and any SPARQL 1.1 compatible endpoint. Technology Built with Python, React, and TypeScript. Created by M Barbieri quot; ] ) ] . # SHACL output sh:property [ sh:path nwo:postalCode ; sh:datatype xsd:string ; sh:pattern "^[0-9]{5} RDF Studio – SPARQL Editor, Ontology Manager & Knowledge Graph Explorer RDF Studio is a free semantic web IDE and training platform for browsing, querying, and editing RDF knowledge graphs. Home of the Northwind RDF use case with 80+ executable SPARQL competency questions (use case stories) and query templates. Key Features Northwind RDF Use Case – A curated training dataset with full OWL ontology, sample data, and 80+ executable SPARQL competency questions with business use case stories following EKGF methodology. Query Library – 80+ categorized queries spanning data exploration, CRUD operations, OWL axioms, taxonomy navigation, federated queries, and graph analytics — each with descriptions and use case context. Query Templates – Reusable SPARQL patterns for basic exploration, data quality checks, and graph analytics that work across any dataset. SPARQL Editor – Full SPARQL 1.1 query editor with syntax highlighting, autocomplete, PREFIX folding, query library, and execution history. Visual Ontology Editor – Create and edit OWL/RDFS classes, properties, and restrictions in an interactive graph editor with draft workflow and layout persistence. SHACL Shapes Editor & Validator – Browse, edit, auto-generate, and validate SHACL shapes with a validation dashboard and maturity scoring. Knowledge Graph Visualization – Interactive graph visualization with multiple layout engines, node expansion, search, and export. Faceted Search – Auto-generated faceted search interfaces from RDF/OWL ontologies with filters, sorting, and pagination. Traversal Query Builder – Cross-class query builder for navigating complex knowledge graph relationships. Taxonomy & Vocabulary Management – SKOS taxonomy browser, vocabulary import (FOAF, Dublin Core, RDFS), and hierarchical tree editing. Multi-Database Support – Connect to external SPARQL endpoints (GraphDB, Virtuoso, Stardog, Neptune, Fuseki). RDF Instance CRUD – Create, read, update, and delete RDF instances with SHACL validation and named graph targeting. Ontology Maturity Scoring – 5-dimension assessment of ontology quality with schema-data drift detection. Supported Standards RDF, RDFS, OWL, OWL 2, SPARQL 1.1, SHACL, SKOS, Turtle, N-Triples, JSON-LD, Dublin Core, FOAF, Schema.org Supported Triple Stores Oxigraph, GraphDB, Virtuoso, Stardog, Amazon Neptune, Apache Jena Fuseki, and any SPARQL 1.1 compatible endpoint. Technology Built with Python, React, and TypeScript. Created by M Barbieri quot; ; ] .
RDF Studio is a free semantic web IDE and training platform for browsing, querying, and editing RDF knowledge graphs. Home of the Northwind RDF use case with 80+ executable SPARQL competency questions (use case stories) and query templates.
RDF, RDFS, OWL, OWL 2, SPARQL 1.1, SHACL, SKOS, Turtle, N-Triples, JSON-LD, Dublin Core, FOAF, Schema.org
Oxigraph, GraphDB, Virtuoso, Stardog, Amazon Neptune, Apache Jena Fuseki, and any SPARQL 1.1 compatible endpoint.
Built with Python, React, and TypeScript.
Created by M Barbieri
rdfs:domain :X
:XShape
owl:DatatypeProperty
owl:inverseOf
sh:inversePath
owl:propertyChainAxiom
owl:oneOf
sh:in
These limits are intentional — the translator produces shapes that are safe and predictable. You can always add more constraints manually.