x12-tidy
Validate and repair malformed ANSI X12 EDI, built piece by piece. The free CLI and Python library behind TidyEDI.
x12-tidy parses permissively and reports strictly: it locates the
interchange envelope even in a malformed file and emits a Diagnostic for every
deviation from the standard rather than bailing on the first. As it grows, each
piece also reconstructs the structure it parsed into a clean, conformant form —
so the end state is not just "here is what is wrong" but "here is a fixed copy."
The audience is a developer who received a bad file from a trading partner and
needs to know exactly what is non-conformant. (If "X12 linter" is what you
searched for, yes, that too.)
Docs
Engineering notes — the method, then one note per piece of the parse, at docs.tidyedi.com:
- The x12-tidy Method — the one idea: earn the delimiters from structure first, then the rest is easy
- Finding the Elusive ISA Line — locating the ISA line when fixed byte offsets and a regex both fail
- Those Pesky Delimiters — reading the four delimiters from a line whose byte offsets have moved
- Reconstructing the ISA Line — rebuilding the canonical 105-byte line once the delimiters are trusted
- Reassembling the Interchange — splitting the body into segments and rejoining it with the ISA line into one payload
- Auditing the Envelope — checking whether the interchange's own bookkeeping (pairing, counts, control numbers) is honest
Using it — docs/using-x12-tidy.md:
the CLI, the tidy() one-call API, the lower-level building blocks, and
formatting your own report.
Reference — design.md
(architecture, the diagnostic-code scheme) ·
docs/diagnostics.md
(every code, generated) ·
the docs/ folder holds
the Markdown sources and PDFs.
Status
| Piece | State |
|---|---|
ISA envelope — locate the ISA line (x12_tidy.envelope.isa.extract_isa_line) |
done |
ISA envelope — recover the four delimiters (x12_tidy.envelope.isa.split_isa_line) |
done |
ISA envelope — reconstruct the canonical line (x12_tidy.envelope.isa.reconstruct_isa_line) |
done |
Whole-document cleanse (x12_tidy.envelope.structure.clean_payload) |
done |
GS / ST / structure — envelope and control-number QA/QC (x12_tidy.envelope.qaqc.check_payload) |
done |
Usage
pip install x12-tidy # or: uv add x12-tidy
x12-tidy check path/to/file.edi # run the checks built so far
x12-tidy codes --area isa # list diagnostic codes
x12-tidy explain isa.leading-bytes # detail for one code
check exit codes: 0 clean (or warnings only), 1 a fatal/error finding,
2 usage / IO problem.
Development
uv sync --extra dev
uv run pre-commit install # once per clone: guards main, regenerates docs
uv run pytest
uv run python scripts/gen_diagnostics_docs.py # after changing codes.py
All work goes on a feature branch and merges via PR — the no-commit-to-branch
hook blocks direct commits to main. Cutting a release:
docs/RELEASING.md.
Design conventions:
- Pure functions over
bytes, neverstr. - Diagnostic codes are
area.specificnames defined only insrc/x12_tidy/diagnostics/codes.py; referenceCode.*symbols, never code strings. Tests assert on the symbol. docs/diagnostics.mdis generated; a pre-commit hook and a CI check keep it in sync withcodes.py.
License
Apache License 2.0 — © 2026 Michael Schertz.
See NOTICE.
"TidyEDI" and the TidyEDI logo are trademarks of Michael Schertz; the license covers the code, not the name or the mark.
Metadata
Release files for x12-tidy 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| x12_tidy-0.1.0.tar.gz | 74.1 kB | With provenance | Details for x12_tidy-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| x12_tidy-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for x12_tidy-0.1.0-py3-none-any.whl |
Total release size: 122.1 kB
Release files / x12_tidy-0.1.0.tar.gz
| Download URL | x12_tidy-0.1.0.tar.gz |
|---|---|
| Size | 74.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9cff04d95ef70c58748a8e599cf904e31e2d785ab0a87f1a9ba608c3cd6ff9c5
|
|
BLAKE2b-256 checksum How to use checksums |
5fc965c7ea6024f81f49a7185abb3c975a9acbbd4c09adb62c9a2526cbdfbafb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.
Transparency logRelease files / x12_tidy-0.1.0-py3-none-any.whl
| Download URL | x12_tidy-0.1.0-py3-none-any.whl |
|---|---|
| Size | 48.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e9373265a7267fb7d5597415409dea3026731c1f3a57f064e570698d84b56504
|
|
BLAKE2b-256 checksum How to use checksums |
d2331acfe61b97571a7eaf53e599a2a0e8970f644d0ccb2c56551c894bd52422
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.
Transparency logSecurity for x12-tidy 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for x12_tidy-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.