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.

Release files for zenfmt 0.3.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zenfmt 0.3.7
File Size Uploaded
zenfmt-0.3.7.tar.gz 475.6 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for zenfmt 0.3.7
File
zenfmt-0.3.7-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
zenfmt-0.3.7-py3-none-musllinux_1_2_x86_64.whl Python 3 none Linux musl 1.2+ x86-64 Details
zenfmt-0.3.7-py3-none-musllinux_1_2_aarch64.whl Python 3 none Linux musl 1.2+ ARM64 Details
zenfmt-0.3.7-py3-none-manylinux_2_17_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details
zenfmt-0.3.7-py3-none-manylinux_2_17_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details
zenfmt-0.3.7-py3-none-macosx_12_0_x86_64.whl Python 3 none macOS 12.0+ x86-64 Details
zenfmt-0.3.7-py3-none-macosx_12_0_arm64.whl Python 3 none macOS 12.0+ ARM64 Details

Total release size: 15.6 MB

Release files / zenfmt-0.3.7.tar.gz

Download URL zenfmt-0.3.7.tar.gz
Size 475.6 kB
Tags Source
SHA-256 checksum
How to use checksums
6e9e7f8d249f50094b32acf38fbfaadeae091487a396ffa3e9270c2ef265a4da
BLAKE2b-256 checksum
How to use checksums
0c954bdd72ec0da37e438df5ef20e9dedef91757ffd4afd5e3ac221530719bc8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / zenfmt-0.3.7-py3-none-win_amd64.whl

Download URL zenfmt-0.3.7-py3-none-win_amd64.whl
Size 1.0 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
f9afb1c9bac8c801d7d0776bad9c976fd1b00a950543ce66b4db4e47f2a59c08
BLAKE2b-256 checksum
How to use checksums
b87f6179d2d516658a225a3156985e7ff4ff1056d09cbfea35da3d451ecedbcf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / zenfmt-0.3.7-py3-none-musllinux_1_2_x86_64.whl

Download URL zenfmt-0.3.7-py3-none-musllinux_1_2_x86_64.whl
Size 3.1 MB
Tags Linux musl 1.2+ x86-64 Python 3
SHA-256 checksum
How to use checksums
800de79fa95ff2c2041e214d2f6d6ee4dfc6da4d5220c0b2ebc65be770e2f76d
BLAKE2b-256 checksum
How to use checksums
64de397f841753b3a05edd15b88c0a060f4238e4b73d33ca3a5eab1ef809cd32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / zenfmt-0.3.7-py3-none-musllinux_1_2_aarch64.whl

Download URL zenfmt-0.3.7-py3-none-musllinux_1_2_aarch64.whl
Size 2.9 MB
Tags Linux musl 1.2+ ARM64 Python 3
SHA-256 checksum
How to use checksums
243043135569dea640e8d0f450092a109f813c67886d58eb073115fbbc5d0916
BLAKE2b-256 checksum
How to use checksums
b7ad9cac0dbf24cd668aabe046324e52671c5b87f5a958de56249fa39442bd75
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / zenfmt-0.3.7-py3-none-manylinux_2_17_x86_64.whl

Download URL zenfmt-0.3.7-py3-none-manylinux_2_17_x86_64.whl
Size 3.1 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
43a7e6ff7fc2d3f6b04a6695768fd823f1270bdc1558f8ff4feb26ee1e9384de
BLAKE2b-256 checksum
How to use checksums
af7a94deda3fac062a5c78506958ccb4fb8f8a4148c908478386758507ab7898
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / zenfmt-0.3.7-py3-none-manylinux_2_17_aarch64.whl

Download URL zenfmt-0.3.7-py3-none-manylinux_2_17_aarch64.whl
Size 3.0 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
8eb15b69e4096c9b9861a823d101a6ad4d3b16ea7e6433dcaf051ee8231dfe49
BLAKE2b-256 checksum
How to use checksums
a85024d81461d8ff5e40062a9134e72f03ffb69cac99cda2d342a0f5bba5522e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / zenfmt-0.3.7-py3-none-macosx_12_0_x86_64.whl

Download URL zenfmt-0.3.7-py3-none-macosx_12_0_x86_64.whl
Size 1.0 MB
Tags Python 3 macOS 12.0+ x86-64
SHA-256 checksum
How to use checksums
182e3dfc66cd195f2b244a4051c32b424791005742613c2bcc9dc51f23d70f1d
BLAKE2b-256 checksum
How to use checksums
e5a69f8c74b4b5d3f82033d8d7b55461ee1615edd7d276ada5f411c0b239f45e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / zenfmt-0.3.7-py3-none-macosx_12_0_arm64.whl

Download URL zenfmt-0.3.7-py3-none-macosx_12_0_arm64.whl
Size 956.8 kB
Tags Python 3 macOS 12.0+ ARM64
SHA-256 checksum
How to use checksums
d567519b6ff8a0becd1402024ed3f079be7745ac288ef4e1f6d508df6f777a12
BLAKE2b-256 checksum
How to use checksums
82da3031956c3971ce9045f31ca024bed6c303c67012318a7aa53431810da0b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

0.3.7 This release

8 release files

0.3.6

8 release files

0.3.5

8 release files

0.3.3

8 release files

0.3.2

8 release files

0.3.1

8 release files

0.3.0

8 release files

0.2.0

8 release files

0.1.0

8 release 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