pyshacl
Python SHACL Validator
What it is and what it does
pySHACL is a pure Python validator that checks whether RDF graphs conform to constraints defined in SHACL (Shapes Constraint Language) shape graphs. It uses rdflib for RDF handling and integrates owlrl for optional OWL2 RL Profile inference on data before validation. The validator can run standalone via command-line or be imported as a Python module; it supports multiple output formats (human-readable, table, Turtle, XML, JSON-LD, N-Triples, N3) and offers advanced features like meta-SHACL validation, SHACL Rules iteration, and optional Oxigraph backend support.
Typical workflows involve loading a data graph and a shapes graph, optionally applying inference rules, and then validating the data against the constraints. The package returns a conformance boolean, a results graph in RDF, and human-readable validation text. It adheres to the W3C SHACL Recommendation and is designed for semantic web and linked data applications where schema validation and data quality checks are critical.
Use it for:
- Validate RDF datasets against organizational data quality rules before ingestion into a knowledge graph.
- Enforce schema constraints on linked data published as part of a semantic web application.
- Perform automated compliance checks on RDF exports from databases or ontology repositories.
- Integrate SHACL validation into data pipelines to catch malformed triples early.
- Test SHACL shape definitions themselves using meta-SHACL before deploying them in production.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Validates RDF graphs against SHACL shape definitions, using rdflib and OWL-RL for semantic constraint checking and optional OWL2 RL Profile inference.
Yes. pySHACL is actively maintained, has low install friction, carries a permissive Apache 2.0 license, and is the standard Python implementation of the W3C SHACL specification. Install it if you work with RDF graphs and need constraint validation; it is production-stable and suitable for both command-line and programmatic use.
Install
pyshacl on PyPI
pip
pip install pyshacluv
uv add pyshaclpoetry
poetry add pyshaclInstalling pyshacl
Before you install
Low install friction with a pure Python wheel distribution. Active maintenance with a release 17 days ago and recent commits; supports Python 3.9 through 3.13.
License in practice
Apache License 2.0 (permissive) allows commercial use, modification, and distribution with minimal restrictions—only requiring license and copyright notice preservation.
Quickstart
from pyshacl import validate
data_graph = "data.ttl"
shacl_graph = "shapes.ttl"
conforms, results_graph, results_text = validate(
data_graph,
shacl_graph=shacl_graph,
inference='rdfs'
)
Requires RDF data and SHACL shape files in a supported format (Turtle, XML, JSON-LD, N-Triples, or N3); rdflib and owlrl must be available.
Verify before relying
- Performance characteristics when validating large RDF graphs or deeply nested shape hierarchies.
- Completeness of SHACL Advanced Features and SHACL-JS support relative to the W3C specification.
- Behavior and error handling when validating against malformed or incomplete SHACL shapes.
Package facts
| License | Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 5 — importlib-metadata, owlrl, packaging, prettytable, rdflib |
| Maintenance | actively maintained — 17 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,058,329/month — #4,426 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pyshacl-0.40.1-py3-none-any.whl
Keywords: Linked Data, Semantic Web, RDF, Graph, Python, SHACL, Shapes, Schema, Validate, Validator
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
owlrlImplements OWL2 RL Profile and RDFS inference…
unclear · top 5,000 on PyPI
spdx3-validateValidates SPDX 3 documents with context-aware…
permissive · top 15,000 on PyPI
rdflibRDFLib is a Python library for parsing,…
permissive · top 1,000 on PyPI
PyShexCParses Shape Expression Compact (ShExC) syntax…
permissive · top 15,000 on PyPI
pyoxigraphPyoxigraph is a Python library that provides…
permissive · top 15,000 on PyPI
spdx-python-modelProvides Python bindings for the SPDX 3 data…
permissive · top 15,000 on PyPI
PyShExPyShEx parses and validates RDF data against…
permissive · top 15,000 on PyPI
CFGraphCFGraph extends rdflib's Graph to read RDF…
permissive · top 15,000 on PyPI
owlready2Owlready2 is a Python module for…
copyleft · top 15,000 on PyPI
rdflib-jsonldProvides JSON-LD parsing and serialization for…
permissive · top 15,000 on PyPI