skillfed

pyshacl

Python SHACL Validator

pyshacl v0.40.1 1.1M downloads/30d#4,426 on PyPI339
Permissive 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) Active released

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 pyshacl

uv

uv add pyshacl

poetry

poetry add pyshacl

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Libraries :: Python ModulesTopic :: Utilities

Tags

RDF graph validationSHACL validatorsemantic web constraintsshape validationlinked data validationRDF schema validationgraph constraint checking
semantic-webrdf-validationlinked-data

More Python Modules packages