Skip to main content

 x12-tidy

PyPI Python CI License: Apache-2.0

Why did your X12 file fail? x12-tidy names every departure from the standard with a byte offset, and hands back a clean, conformant copy.

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:

Using itdocs/using-x12-tidy.md: the CLI, the tidy() one-call API, the lower-level building blocks, and formatting your own report.

Referencedesign.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, never str.
  • Diagnostic codes are area.specific names defined only in src/x12_tidy/diagnostics/codes.py; reference Code.* symbols, never code strings. Tests assert on the symbol.
  • docs/diagnostics.md is generated; a pre-commit hook and a CI check keep it in sync with codes.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

x12_tidy-0.1.0.tar.gz (74.1 kB view details)

Uploaded Source

Built Distribution

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

x12_tidy-0.1.0-py3-none-any.whl (48.0 kB view details)

Uploaded Python 3

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

Hashes for x12_tidy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9cff04d95ef70c58748a8e599cf904e31e2d785ab0a87f1a9ba608c3cd6ff9c5
MD5 8125e1c32c0362ea12c14203721704bd
BLAKE2b-256 5fc965c7ea6024f81f49a7185abb3c975a9acbbd4c09adb62c9a2526cbdfbafb

See more details on using hashes here.

Provenance

The following attestation bundles were made for x12_tidy-0.1.0.tar.gz:

Publisher: release.yml on tidyedi/x12-tidy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for x12_tidy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e9373265a7267fb7d5597415409dea3026731c1f3a57f064e570698d84b56504
MD5 aab75222891b1e41dac55e74707eef4f
BLAKE2b-256 d2331acfe61b97571a7eaf53e599a2a0e8970f644d0ccb2c56551c894bd52422

See more details on using hashes here.

Provenance

The following attestation bundles were made for x12_tidy-0.1.0-py3-none-any.whl:

Publisher: release.yml on tidyedi/x12-tidy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

0.0.1

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