skillfed

xmlschema

An XML Schema validator and decoder

xmlschema v4.3.2 8.5M downloads/30d#1,618 on PyPI477
Permissive license MIT Active released

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 xmlschema

uv

uv add xmlschema

poetry

poetry add xmlschema

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: Information TechnologyIntended Audience :: Science/ResearchOperating System :: OS IndependentProgramming Language :: PythonProgramming 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.14Programming Language :: Python :: 3.15Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: LibrariesTopic :: Text Processing :: Markup :: XML

Tags

XML schema validationXSD validatorXML to Python conversionXML data decodingschema-based XML processing
xml-schemadata-validationserialization

More Libraries packages