Skip to main content

zenfmt

Universal document conversion as a typed, dependency-free Python library. zenfmt reads 19 formats—DOCX, DOC, ODT, RTF, XLSX, XLS, XLSB, ODS, CSV, PPTX, PPT, ODP, EPUB, PDF, HTML, Markdown, AsciiDoc, reStructuredText, and plain text—and writes clean Markdown through a native engine written in Zig. The wheel bundles the engine: no runtime dependencies, subprocesses, or network downloads are required, and the GIL is released during conversion.

pip install zenfmt
import zenfmt

# A str is always a path; the result is the whole in-memory ensemble:
# artifact bytes, embedded resources, the canonical manifest, and reports.
conversion = zenfmt.convert("report.docx")
print(conversion.text)
for report in conversion.reports:
    print(report.code, report.problem)

# Bytes are explicit; the source format is named or sniffed.
conversion = zenfmt.convert(uploaded_bytes, name="upload.docx", to="markdown")

# An output path selects transactional publication: the artifact, its media,
# and a manifest land together or not at all. Graded strictness refuses
# priced fidelity loss before anything is written.
conversion = zenfmt.convert(
    "report.docx", output="build/report.md", strict="structure"
)

Failures raise a compact exception tree (ConversionError, LimitExceededError, UnknownFormatError, …) whose messages answer the same four questions as the engine's CLI diagnostics — what happened, where, what it costs, and what you can do. Reusable policy lives in immutable zenfmt.Converter values; there is no global configuration or environment lookup. zenfmt.formats() enumerates the compiled-in format capabilities.

Every library error includes structured facts and an actionable hint. Handle stable codes in application logic and render the message for people:

try:
    zenfmt.convert(uploaded_bytes, name="upload.docx")
except zenfmt.ConversionError as error:
    log.info("conversion failed", extra={"code": error.code})
    print(error.hint)

Security and authority

A string is always a path. Passing a path explicitly authorizes zenfmt to read that file and, when present, its adjacent digest-bound .zenfmt.json manifest. Passing bytes or a binary reader grants no filesystem authority: name is display-only, is never opened, and no adjacent file is inspected. External resource references are reported in conversion.resources but are never fetched. The runtime does not read configuration from the environment, follow includes, resolve external entities, discover plugins, or use the network.

Conversion is bounded by zenfmt.Limits; the defaults cap input, decoded text, archive expansion, document structure, reports, embedded resources, and artifact output. Services handling large or untrusted documents should lower those limits and publish path output inside a per-job directory with suitable permissions and quotas. Path publication is transactional and refuses to replace an existing artifact ensemble unless overwrite=True.

The native engine runs inside the Python process with that process's authority. A wheel is not a sandbox. Workloads that need a stronger isolation boundary should perform conversion in a restricted worker process or container. Independent calls are thread-safe; create worker processes before starting conversion threads, or use the multiprocessing spawn start method.

Wheels are published for Linux (manylinux and musl, x86_64 and aarch64), macOS 12+ (x86_64 and arm64), and Windows x86_64, for CPython 3.10–3.14. Building from the source distribution requires only a Zig toolchain — the sdist carries the complete engine source under engine/.

CLI archives and Python wheels are attached to each GitHub release. This package is the Python surface of the zenfmt monorepo; the engine, design records (ZDS 0014 covers this library), and development workflow live there.

zenfmt is authored by Vikrant Rathore with assistance from Ronak Rathore.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zenfmt-0.3.2.tar.gz (472.5 kB view details)

Uploaded Source

Built Distributions

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

zenfmt-0.3.2-py3-none-win_amd64.whl (1.0 MB view details)

Uploaded Python 3Windows x86-64

zenfmt-0.3.2-py3-none-musllinux_1_2_x86_64.whl (3.1 MB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

zenfmt-0.3.2-py3-none-musllinux_1_2_aarch64.whl (2.9 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

zenfmt-0.3.2-py3-none-manylinux_2_17_x86_64.whl (3.1 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

zenfmt-0.3.2-py3-none-manylinux_2_17_aarch64.whl (2.9 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

zenfmt-0.3.2-py3-none-macosx_12_0_x86_64.whl (1.0 MB view details)

Uploaded Python 3macOS 12.0+ x86-64

zenfmt-0.3.2-py3-none-macosx_12_0_arm64.whl (951.1 kB view details)

Uploaded Python 3macOS 12.0+ ARM64

File details

Details for the file zenfmt-0.3.2.tar.gz.

File metadata

  • Download URL: zenfmt-0.3.2.tar.gz
  • Upload date:
  • Size: 472.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for zenfmt-0.3.2.tar.gz
Algorithm Hash digest
SHA256 55aa30888424dcc2977c043bf864c543100bbaaaac69544fd5cece0bef16d96b
MD5 11bb66c31e19b2d1f28296d4c3a33479
BLAKE2b-256 b2e1358fda0f873c06b741fc0c638d0aad7ccbf68cebfabf3048890c06e490c8

See more details on using hashes here.

File details

Details for the file zenfmt-0.3.2-py3-none-win_amd64.whl.

File metadata

  • Download URL: zenfmt-0.3.2-py3-none-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for zenfmt-0.3.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 ed4eec4fc8661e87e757bccee99b3c81c0094e69b1918f434a4d6d77e6d4fc93
MD5 e1e2aaec5ae5a7aa91abfaa7fc3d0a23
BLAKE2b-256 6c96f78b56d3a56d681c482ecfd0d85e05493a365960d3b4931c2963f859b949

See more details on using hashes here.

File details

Details for the file zenfmt-0.3.2-py3-none-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for zenfmt-0.3.2-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c3976dd7cc82acd713c52d88d37f8fd7fc16609e46ed223f3cdd95e8edb613ca
MD5 a010e291726ddf0b19c3dbcb2dda92c0
BLAKE2b-256 85c7578ff75c6dd1bebb2173df9c6c5c0ba18f9d8b70e1a0fbef0940cc06682f

See more details on using hashes here.

File details

Details for the file zenfmt-0.3.2-py3-none-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for zenfmt-0.3.2-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 15e5602f8461c03ec091fd05839cf045eaaa07710a6a49db6cf766356955be1d
MD5 366e0889c5d5a6975ac3a810edd70000
BLAKE2b-256 4f85e32607e5b02998603f012b3fd738579d3dae23c9deb2a218c7e1f4e8bb96

See more details on using hashes here.

File details

Details for the file zenfmt-0.3.2-py3-none-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for zenfmt-0.3.2-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 56f55b2b1a047d9787edbd288a7b8c1fa2f8b142323b7e203668bce646439088
MD5 6c430c81a88b0b964c61aa8d34bac94e
BLAKE2b-256 2d50a3e62b3cae149f231f9765595406db9f7955b9bdc4ee055e338ba5b8c544

See more details on using hashes here.

File details

Details for the file zenfmt-0.3.2-py3-none-manylinux_2_17_aarch64.whl.

File metadata

File hashes

Hashes for zenfmt-0.3.2-py3-none-manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 f348b713a33c425f7350657a8f3c29a75e183c3c5adca585f66ea843fe1f7366
MD5 d9c0db3fa78c4dc4d243cd4b421d8ddf
BLAKE2b-256 4668b5af1ca5df047a85e78255446f57a77b963ba3eef4b52dc0082e4a283dbd

See more details on using hashes here.

File details

Details for the file zenfmt-0.3.2-py3-none-macosx_12_0_x86_64.whl.

File metadata

File hashes

Hashes for zenfmt-0.3.2-py3-none-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 b18c7340c97a9b4c9852fba23a92c905b699d71ce188eedf559a04ae3be7a7e4
MD5 2ba01c18e0e261e95503047b471ef511
BLAKE2b-256 73d3d4ecaec5f8f87d94765b2a8c8af6cdbb56063933229375afccf459db29db

See more details on using hashes here.

File details

Details for the file zenfmt-0.3.2-py3-none-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for zenfmt-0.3.2-py3-none-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 9c4a84d14a9460cfbf932a4a1aaca4d1c558b01ff7dcfb24bdaaac766244e654
MD5 de4b7a64e34087778674ded45161b3fc
BLAKE2b-256 b4ca83e55e828d36692cb12ebb21355ce243bfcafef2ac3ea2a9dcdd92a4f63d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page