drafthorse
Python ZUGFeRD XML implementation
Decision gist · record as of 2026-08-14
Yes, if you need to generate or parse ZUGFeRD invoices for German or EU B2B workflows. The library is actively maintained, has low install friction, carries no known vulnerabilities, and is permissively licensed. Install with caution if your invoices require strict profile-level validation or if you need to parse PDF files directly—neither is supported.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires a valid ZUGFeRD XML file to parse; PDF attachment requires an existing PDF/A-3 compliant PDF file.
- Low install friction with only two runtime dependencies (lxml and pypdf).
- Actively maintained with recent releases; maintainers note turnaround on issues may be longer than usual due to competing priorities, but the library is kept functional for production use in the pretix-zugferd module.
License · maintenance · safety
Apache License (permissive) — Apache License 2.0 permits commercial and private use with minimal restrictions. PDF handling code is derived from factur-x (BSD license). Bundled XSD schemas and samples are owned by FeRD and released under a proprietary license that allows free bundling.
last release 2025-09-15 (333 days) · last repo commit 2026-06-02 · 176 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 132,686 downloads/mo, #11,542 on PyPI
Alternatives
Verify before relying
from drafthorse.models.document import Document
samplexml = open("sample.xml", "rb").read()
doc = Document.parse(samplexml)
print(doc.trade.agreement.seller.name)- Whether strict parsing mode (default True) is appropriate for your invoice sources or if lenient parsing is needed.
- Performance characteristics when handling large batches of invoices or complex line items.
- Whether all ZUGFeRD 2.3 parameters your use case requires are fully supported.
What it is and what it does
drafthorse is a low-level Python implementation of the ZUGFeRD XML format, a German standard for digital B2B invoicing. It models the ZUGFeRD data structure directly without abstraction, allowing you to set and parse all parameters defined in ZUGFeRD 2.3. The library can generate ZUGFeRD XML from Python objects, parse existing ZUGFeRD XML files, validate output against official XSD schemas, and attach the resulting XML to PDF files for transmission. Profile level (basic, comfort, extended) is detected automatically from the XML data.
The library does not parse PDF files themselves—it only attaches pre-generated ZUGFeRD XML to existing PDFs. All generated XML is validated against the official schemas, though profile-level compliance is not enforced. It depends on lxml for XML handling and pypdf for PDF manipulation, keeping the dependency footprint small.
Use it for
- Generate compliant ZUGFeRD invoices programmatically for B2B transactions in Germany and EU markets.
- Parse received ZUGFeRD XML from incoming invoices to extract seller, buyer, and line-item data.
- Embed ZUGFeRD XML into PDF/A-3 files to create machine-readable digital invoices for archival.
- Validate invoice XML against ZUGFeRD 2.3 specification before transmission or storage.
- Integrate invoice generation into billing systems like pretix to meet upcoming German B2B digital invoice requirements.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need to generate or parse ZUGFeRD invoices for German or EU B2B workflows.
The library is actively maintained, has low install friction, carries no known vulnerabilities, and is permissively licensed. Install with caution if your invoices require strict profile-level validation or if you need to parse PDF files directly—neither is supported.
Install
drafthorse on PyPI
Before you install
Low install friction with only two runtime dependencies (lxml and pypdf). Actively maintained with recent releases; maintainers note turnaround on issues may be longer than usual due to competing priorities, but the library is kept functional for production use in the pretix-zugferd module.
Requires a valid ZUGFeRD XML file to parse; PDF attachment requires an existing PDF/A-3 compliant PDF file.
License in practice
Apache License 2.0 permits commercial and private use with minimal restrictions. PDF handling code is derived from factur-x (BSD license). Bundled XSD schemas and samples are owned by FeRD and released under a proprietary license that allows free bundling.
Quickstart
from drafthorse.models.document import Document
samplexml = open("sample.xml", "rb").read()
doc = Document.parse(samplexml)
print(doc.trade.agreement.seller.name)
Verify before relying
- Whether strict parsing mode (default True) is appropriate for your invoice sources or if lenient parsing is needed.
- Performance characteristics when handling large batches of invoices or complex line items.
- Whether all ZUGFeRD 2.3 parameters your use case requires are fully supported.
Package facts
| License | Apache License permissive |
| Python support | Not specified |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 2 packageslxmlpypdf |
| Maintenance | Actively maintained 333 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 132,686 / month, #11,542 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Intended Audience :: DevelopersIntended Audience :: Other AudienceLicense :: OSI Approved :: Apache Software LicenseProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9 |
Evidence: drafthorse-2025.2.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “zugferd xml invoice generation”
- drafthorseGenerates and parses ZUGFeRD XML invoice documents, and attaches them…
- factur-xGenerates, validates, and extracts Factur-X, Order-X, and UBL…
- BrazilFiscalReportConverts Brazilian electronic invoice XML files (NF-e, CT-e, MDF-e,…
Give your agent the search over MCP, or paste the wish link into any chat.
More Markup packages
PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.
A Python markdown parser that converts markdown to HTML following the CommonMark specification, with support for plugins and custom syntax rules.
Install it if you need reliable markdown-to-HTML conversion.
Beautiful Soup parses HTML and XML documents into a navigable tree, providing Pythonic methods to search, iterate, and modify the parsed content.
Install it if you need to parse or extract data from markup documents.
et_xmlfile writes large XML files with minimal memory overhead by serializing elements to disk as they are created, rather than holding the entire tree in memory.
Install it if incremental XML writing fits your use case; skip it if your XML documents are small or you already use lxml.
Parses and edits TOML files while preserving formatting, comments, and structure, then serializes them back with layout intact.
Install it if you're building tools that touch TOML files and user readability of the source matters.
Parses Python docstrings in ReST, Google, Numpydoc, and Epydoc formats, extracting structured information like descriptions, parameters, return types, and exceptions.
Install it if you need to programmatically read and extract structured data from Python docstrings.
See also BrazilFiscalReport · factur-x · sepaxml · unittest-xml-reporting · pdfminer · cloudmersive-convert-api-client · endesive · xlwt · fints · kreuzberg