xmlschema
An XML Schema validator and decoder
What it is and what it does
xmlschema is a Python implementation of XML Schema (XSD) that validates XML documents and converts between XML, Python data structures, and JSON. It supports both XSD 1.0 and XSD 1.1 standards and includes built-in base schemas for offline operation. The library was originally developed to handle schema-based XML processing for the MaX European research project but is applicable to any XML Schema validation or data binding task.
The package provides validation in strict, lax, and skip modes, protects against XML attacks by forbidding entities, and offers XPath-based APIs for navigating schemas. It can decode XML into nested Python dictionaries with type-aware values, encode Python data back to XML, and generate static code using Jinja2 templates. The single runtime dependency (elementpath) keeps installation lightweight.
Use it for:
- Validate XML configuration files or data exports against a schema before processing.
- Decode XML documents into Python dictionaries for programmatic access to typed data.
- Encode Python data structures back to XML while enforcing schema constraints.
- Build XML data bindings or generate Python classes from XSD schemas.
- Protect against XML entity attacks by parsing untrusted XML with entity forbidding enabled.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Validates XML documents against XSD schemas and converts XML to/from Python data structures and JSON.
Yes. xmlschema is actively maintained, has no known vulnerabilities, requires only Python 3.10+, and carries a permissive MIT license. It is the standard choice for schema-based XML processing in Python when XSD validation or structured XML-to-Python conversion is needed.
Install
xmlschema on PyPI
pip
pip install xmlschemauv
uv add xmlschemapoetry
poetry add xmlschemaInstalling xmlschema
Before you install
Low friction: pure Python wheel with a single runtime dependency (elementpath). Active maintenance with a release 45 days ago and ongoing commits.
License in practice
MIT license permits unrestricted use, modification, and distribution in commercial and private projects.
Quickstart
pip install xmlschema
import xmlschema
my_schema = xmlschema.XMLSchema('path/to/schema.xsd')
my_schema.is_valid('path/to/document.xml')
data = my_schema.to_dict('path/to/document.xml')
Requires Python 3.10 or later.
Verify before relying
- Whether XSD 1.1 support is production-ready or still experimental relative to XSD 1.0.
- Performance characteristics when validating large XML files or deeply nested schemas.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — elementpath |
| Maintenance | actively maintained — 45 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 8,481,770/month — #1,618 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: xmlschema-4.3.2-py3-none-any.whl
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
PyXB-XPyXB-X generates Python classes from XMLSchema…
permissive · top 15,000 on PyPI
xsdataxsdata generates Python dataclasses from XML…
permissive · top 5,000 on PyPI
xsdata-pydanticGenerates pydantic models from XML and JSON…
permissive · top 15,000 on PyPI
schemaValidates Python data structures (dicts, lists,…
permissive · top 1,000 on PyPI
event-modelDefines and validates the formal data model for…
permissive · top 15,000 on PyPI
fastjsonschemaValidates JSON data against JSON Schema…
permissive · top 1,000 on PyPI
jsonschema-rsjsonschema-rs validates JSON data against JSON…
permissive · top 5,000 on PyPI
voluptuousVoluptuous validates Python data structures…
permissive · top 5,000 on PyPI
kubernetes-validateValidates Kubernetes resource definitions…
permissive · top 15,000 on PyPI
doclangDocLang is a reference toolkit for validating…
permissive · top 5,000 on PyPI