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.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file x12_tidy-0.1.0.tar.gz.
File metadata
- Download URL: x12_tidy-0.1.0.tar.gz
- Upload date:
- Size: 74.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9cff04d95ef70c58748a8e599cf904e31e2d785ab0a87f1a9ba608c3cd6ff9c5
|
|
| MD5 |
8125e1c32c0362ea12c14203721704bd
|
|
| BLAKE2b-256 |
5fc965c7ea6024f81f49a7185abb3c975a9acbbd4c09adb62c9a2526cbdfbafb
|
Provenance
The following attestation bundles were made for x12_tidy-0.1.0.tar.gz:
Publisher:
release.yml on tidyedi/x12-tidy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
x12_tidy-0.1.0.tar.gz -
Subject digest:
9cff04d95ef70c58748a8e599cf904e31e2d785ab0a87f1a9ba608c3cd6ff9c5 - Sigstore transparency entry: 2754013457
- Sigstore integration time:
-
Permalink:
tidyedi/x12-tidy@11607e7439c47b324269f08e9a160b3922f159a6 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/tidyedi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@11607e7439c47b324269f08e9a160b3922f159a6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file x12_tidy-0.1.0-py3-none-any.whl.
File metadata
- Download URL: x12_tidy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 48.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e9373265a7267fb7d5597415409dea3026731c1f3a57f064e570698d84b56504
|
|
| MD5 |
aab75222891b1e41dac55e74707eef4f
|
|
| BLAKE2b-256 |
d2331acfe61b97571a7eaf53e599a2a0e8970f644d0ccb2c56551c894bd52422
|
Provenance
The following attestation bundles were made for x12_tidy-0.1.0-py3-none-any.whl:
Publisher:
release.yml on tidyedi/x12-tidy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
x12_tidy-0.1.0-py3-none-any.whl -
Subject digest:
e9373265a7267fb7d5597415409dea3026731c1f3a57f064e570698d84b56504 - Sigstore transparency entry: 2754013462
- Sigstore integration time:
-
Permalink:
tidyedi/x12-tidy@11607e7439c47b324269f08e9a160b3922f159a6 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/tidyedi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@11607e7439c47b324269f08e9a160b3922f159a6 -
Trigger Event:
push
-
Statement type: