Skip to main content
Back to Standards
Shapes Constraint Language logo

Shapes Constraint Language

SHACL

A W3C Recommendation for describing and validating RDF graphs. SHACL defines shapes that constrain the content, structure, and values of graph nodes, including property cardinality, datatype restrictions, string patterns, and logical combinations. The specification includes SHACL Core for built-in constraint types and SHACL-SPARQL for custom constraints expressed in SPARQL. Companion documents define SHACL Advanced Features (rules and inference), JavaScript extensions, and a compact syntax. Published as a W3C Recommendation on 20 July 2017 by the RDF Data Shapes Working Group.

Overview

The Shapes Constraint Language (SHACL) is a W3C standard for describing and validating RDF graphs. In the semantic web ecosystem, where data is expressed as flexible, schema-optional RDF triples, SHACL provides the mechanism to declare what valid data should look like and to check whether actual data conforms. Published as a W3C Recommendation in July 2017, it has been adopted by virtually all major RDF database vendors and is a cornerstone technology for data quality in knowledge graph deployments.

Background

SHACL emerged from the W3C RDF Data Shapes Working Group, which was chartered in 2014 to address a long-standing gap in the RDF technology stack: the lack of a standard way to validate graph data. While OWL and RDFS provide vocabulary for defining ontologies, they were designed for inference rather than validation. Earlier community efforts such as SPIN (SPARQL Inferencing Notation) demonstrated the need and feasibility of shape-based validation. The first public working draft appeared in October 2015, and after extensive community review, SHACL became a W3C Recommendation on 20 July 2017, edited by Holger Knublauch and Dimitris Kontokostas.

Purpose and Scope

SHACL allows users to define "shapes" that describe expected characteristics of nodes in an RDF graph. A shape can specify property constraints (cardinality, datatype, value ranges, string patterns), structural requirements (class membership, path traversal), and logical combinations of conditions. When a SHACL processor validates a data graph against a shapes graph, it produces a validation report identifying violations, warnings, and informational findings -- complete with severity levels and optional fix suggestions.

The specification comprises several parts:

Component Status Description
SHACL Core W3C Recommendation Built-in constraint types, shape syntax, target declarations
SHACL-SPARQL W3C Recommendation Custom constraints expressed in SPARQL
SHACL Advanced Features W3C Note Rules, inference, user-defined functions
SHACL JavaScript Extensions W3C Note Constraints and rules in JavaScript
SHACL Compact Syntax Community Report Abbreviated human-readable syntax

Key Concepts

Node shapes describe characteristics of specific graph nodes, such as requiring them to be URIs or literals of a particular type. Property shapes describe values reachable via a path from a node, specifying constraints like minimum count, maximum count, allowed datatypes, or pattern matching. Targets connect shapes to the data they describe, typically by class membership but also by explicit node, subject/object of a predicate, or SPARQL query.

Governance and Maintenance

SHACL is maintained by the W3C. The core recommendation is stable, while companion specifications (Advanced Features, JavaScript Extensions, Compact Syntax) continue development through the SHACL Community Group. The European Commission has assessed SHACL favorably for use in European interoperability frameworks.

Notable Implementations

SHACL is supported by most commercial RDF platforms including Cambridge Semantics (Anzo), eccenca Corporate Memory, Franz (AllegroGraph), Ontotext (GraphDB), Stardog, TopQuadrant, and Metaphacts. Open-source implementations include TopBraid SHACL API (Java/Apache Jena), pySHACL (Python), dotNetRDF SHACL (.NET), Eclipse RDF4J, and the SHACL Playground (JavaScript). Even property-graph systems like Neo4j have added SHACL support.

Related Standards

  • OWL -- Web Ontology Language for defining class hierarchies and inference rules; complementary to SHACL's validation focus
  • SKOS -- Simple Knowledge Organization System for controlled vocabularies, whose data can be validated using SHACL shapes
  • ShEx (Shape Expressions) -- An alternative RDF validation language with a different design philosophy

Further Reading