Skip to main content

Modern XML & JSON Bindings for Python 3.12+

image docs Coverage image image


pyxsdata is a complete, modern data binding library for Python 3.12+ allowing developers to access and use XML and JSON documents as simple objects rather than using DOM.

The code generator supports XML schemas, DTD, WSDL definitions, XML & JSON documents. It produces simple dataclasses or Pydantic v2 models with type hints and binding metadata.

The included XML and JSON parser/serializer are highly optimized and adaptable, with multiple handlers and configuration properties.

About pyxsdata (Modern Fork of xsdata)

pyxsdata is a modernized successor and fork of xsdata designed exclusively for Python 3.12+ and actively maintained with modern tooling.

Key Enhancements over Legacy xsdata

  • Significantly Faster Deserialization: Up to 54% faster XML parsing (over 2x throughput) than legacy xsdata through cached child node lookups, direct scalar and proxy converter fast paths, static method binding, optimized converter dispatch, MRO caching, and slice-free intermediate object collection (eliminating ~1.5 million redundant function calls per 10,000 items).
  • Unified Native Pydantic v2: Consolidates xsdata-pydantic directly into the core library under pyxsdata.pydantic with dedicated --output pydantic generation and drop-in parsers/serializers.
  • Python 3.12+ Architecture: Exclusively leverages PEP 695 generics (class Foo[T]: ...), type union syntax (X | Y), pattern matching, and kw_only dataclasses.
  • Ultra-Fast C++ pugixml Support: First-class support for constant-memory pull-parsing via pugixml (pip install "pyxsdata[pugixml]").
  • Modern Packaging & Tooling: Managed and built with Astral uv, statically type checked with Astral ty with zero diagnostics, and formatted with ruff.
  • Active & Responsive Maintenance: Regular dependency updates, modern CI packaging, and active community maintenance.

Getting started

$ # Install all dependencies including CLI, LXML, SOAP, and Pydantic
$ pip install "pyxsdata[cli,lxml,soap,pydantic]"
$ # Generate models
$ pyxsdata generate tests/fixtures/primer/order.xsd --package tests.fixtures.primer
>>> from tests.fixtures.primer import PurchaseOrder
>>> from pyxsdata.formats.dataclass.parsers import XmlParser
>>>
>>> parser = XmlParser()
>>> order = parser.parse("tests/fixtures/primer/sample.xml", PurchaseOrder)
>>> order.bill_to
Usaddress(name='Robert Smith', street='8 Oak Avenue', city='Old Town', state='PA', zip=Decimal('95819'), country='US')

Pydantic Support

Generate Pydantic v2 models directly with --output pydantic:

$ pyxsdata generate tests/fixtures/primer/order.xsd --output pydantic --package myapp.models
>>> from pyxsdata.pydantic.bindings import XmlParser
>>> parser = XmlParser()
>>> order = parser.from_string(xml_text, PurchaseOrder)
>>> order.model_dump()

Check the documentation for more ✨✨✨

Features

Code Generator

  • XML Schemas 1.0 & 1.1
  • WSDL 1.1 definitions with SOAP 1.1 bindings
  • DTD external definitions
  • Directly from XML and JSON Documents
  • Extensive configuration to customize output
  • Pluggable code writer for custom output formats (Standard Dataclasses, Pydantic v2)

Default Output

  • Pure Python 3.12+ dataclasses or Pydantic models with metadata
  • Modern type hints with support for forward references and unions
  • Enumerations and inner classes
  • Support namespace qualified elements and attributes

Data Binding

  • XML and JSON parser, serializer
  • PyCode serializer
  • Handlers and Writers based on lxml and native xml python
  • Support wildcard elements and attributes
  • Support xinclude statements and unknown properties
  • Native Pydantic v2 support (pyxsdata.pydantic)
  • Fully type-checked with Astral ty

Changelog: 0.0.0

  • Modernized for Python 3.12+ minimum.
  • Consolidated xsdata-pydantic into core library as pyxsdata.pydantic.
  • Replaced mypy with Astral's static type checker ty.
  • Standardized CLI tool to pyxsdata.
  • Documentation powered by Zensical.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyxsdata-1.1.0.tar.gz (444.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyxsdata-1.1.0-py3-none-any.whl (247.2 kB view details)

Uploaded Python 3

File details

Details for the file pyxsdata-1.1.0.tar.gz.

File metadata

  • Download URL: pyxsdata-1.1.0.tar.gz
  • Upload date:
  • Size: 444.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pyxsdata-1.1.0.tar.gz
Algorithm Hash digest
SHA256 94e4111ed0a0ff0a8f1b77dcdc97b5ff4060c0aa51d69dda34456564a64879a4
MD5 e5ebc5cb09d938f4d44083030c42c3f6
BLAKE2b-256 64f1353b02b71345aaf0a1bcff6839c8f9cee5d7fa674b61f47f77016a212803

See more details on using hashes here.

File details

Details for the file pyxsdata-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyxsdata-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 247.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pyxsdata-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5ff29a62aa1439baa6a1ce36c036ce9714ab57ea0ca4d0b28f87148a725bc2ee
MD5 4ee19e2f3ed4bfe892f1efe7ebb58cae
BLAKE2b-256 2952f59ae91c4862f8231e97ee31eca353c9abd8db5d4c20b05ae5bdd996c42f

See more details on using hashes here.

Release history Release notifications | RSS feed

1.3.1

2 files

1.3.0

2 files

1.2.2

2 files

1.2.1

2 files

1.2.0

2 files

1.1.1

2 files

This release

1.1.0 This release

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

0.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page