pyx12
HIPAA X12 validator, parser and converter
What it is and what it does
Pyx12 is a HIPAA-focused X12 EDI parser and validator that reads ANSI X12 data files and validates them against X12 Implementation Guidelines. It generates standard 997 (for 4010) and 999 (for 5010) functional acknowledgments, detects and can fix common structural errors (loop/segment counting, line breaks), and converts between X12 and XML representations. The package ships with implementation-guide maps for multiple transaction types and versions; its design is transaction-agnostic, so new X12 transaction types can be added by registering new XML maps.
The library exposes a Python API for iterating over X12 loops and segments, reading and modifying values, and checking segment existence. It also provides command-line tools (x12valid, x12norm) for validation and normalization workflows. The single runtime dependency is defusedxml, used for safe XML parsing. Maintenance is active, with support for modern Python versions (3.11–3.14) and no known vulnerabilities.
Use it for:
- Validate incoming healthcare EDI claims (837) or eligibility requests (270) against HIPAA X12 standards before processing
- Convert X12 EDI files to XML for integration with systems that consume structured XML data
- Generate 997/999 functional acknowledgments to confirm receipt and validation status of X12 documents
- Normalize malformed X12 files by fixing segment/loop counts and line-break issues before downstream processing
- Build healthcare data pipelines that parse and extract specific claim or eligibility data from X12 loops and segments
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Pyx12 parses, validates, and converts ANSI X12 EDI documents against X12 Implementation Guidelines, generating 997/999 acknowledgments and translating to/from XML representations.
Yes. Pyx12 is a stable, actively maintained library with low install friction, no security vulnerabilities, and a permissive license. It is the standard choice for X12 EDI parsing and validation in Python, especially for healthcare workflows. Install it if you need to work with ANSI X12 documents or HIPAA EDI compliance.
Install
pyx12 on PyPI
pip
pip install pyx12uv
uv add pyx12poetry
poetry add pyx12Installing pyx12
Before you install
Low friction: pure Python wheel with a single runtime dependency (defusedxml). Active maintenance with a recent release (101 days ago) and steady repository activity. Supports current Python versions (3.11–3.14).
License in practice
BSD permissive license allows commercial and private use with minimal restrictions, making it suitable for proprietary healthcare applications.
Quickstart
import pyx12.x12context
src = pyx12.x12context.X12ContextReader(param, errh, fd_in)
for datatree in src.iter_segments('2300'):
for loop2400 in datatree.select('2400'):
value = loop2400.get_value('SV101')
loop2400.set_value('SV102', 'xx')
Requires Python 3.11 or later. X12 Implementation Guide maps must be present in pyx12/map/ for the transaction type and version being parsed.
Verify before relying
- Whether the package handles all common X12 transaction types (270, 271, 276, 277, 278, 834, 837, 841) or only a subset
- Performance characteristics when processing large EDI files or high-volume streams
- Whether custom validation rules or code lists can be extended beyond the bundled maps
Package facts
| License | BSD (permissive) |
| Python support | supports the current Python release (>=3.11) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — defusedxml |
| Maintenance | actively maintained — 101 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 260,401/month — #8,397 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pyx12-4.0.0-py3-none-any.whl
Keywords: x12, hipaa, healthcare, edi
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
pydifactPydifact parses and serializes UN/EDIFACT…
permissive · top 15,000 on PyPI
hl7Parses HL7 version 2.x medical messages into…
permissive · top 15,000 on PyPI
swagger-spec-validatorValidates Swagger/OpenAPI specifications…
permissive · top 15,000 on PyPI
hl7apyHL7apy parses, creates, and validates HL7 v2.x…
permissive · top 15,000 on PyPI
bids-validatorValidates that brain imaging datasets conform…
permissive · top 15,000 on PyPI
word2numberConverts written-out number words (like "twenty…
permissive · top 5,000 on PyPI
roman-numeralsConverts between integers and Roman numerals,…
permissive · top 5,000 on PyPI
ofxtoolsParses, generates, and converts Open Financial…
copyleft · top 15,000 on PyPI
iregexp-checkValidates regular expressions against RFC 9485…
permissive · top 15,000 on PyPI
rfc3986-validatorValidates URLs and URI references against the…
permissive · top 1,000 on PyPI