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
Built Distributions
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 zenfmt-0.3.3.tar.gz.
File metadata
- Download URL: zenfmt-0.3.3.tar.gz
- Upload date:
- Size: 472.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
543a68bba0dc288035b82cec3c9093c62b847914cc73ba9f6e547ed4422f5990
|
|
| MD5 |
67962569083ea6377b9e11c9ca191856
|
|
| BLAKE2b-256 |
3d8d8eca8ff04dd830ad9fde6074d96119c77ea48efc178503409733351e3e21
|
File details
Details for the file zenfmt-0.3.3-py3-none-win_amd64.whl.
File metadata
- Download URL: zenfmt-0.3.3-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
160581bad6ff053620f201f9e9e52f9745fd727fc8b61587c08a3992062de817
|
|
| MD5 |
540d1f8d9ce7eae79bf6e9de0d631f22
|
|
| BLAKE2b-256 |
41c22f14b21dc18438de1105b3a85249d6c4a2ee109075547769633f10ee2605
|
File details
Details for the file zenfmt-0.3.3-py3-none-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: zenfmt-0.3.3-py3-none-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 3.1 MB
- Tags: Python 3, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a3a6aa992cd41ca3b4eb76023bc8460da3bec341dcab935c8214f04485c3449
|
|
| MD5 |
4461e2089aa415bd4226de2229863e92
|
|
| BLAKE2b-256 |
3e2558d4bab9eb6c0897d8f2b2e6da772badc91d14db17346d6259d5b87265fd
|
File details
Details for the file zenfmt-0.3.3-py3-none-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: zenfmt-0.3.3-py3-none-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 2.9 MB
- Tags: Python 3, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ec4c983d5bae169ee7933099ef2a28575fb8d9b97ea76b56c1d89521408b228
|
|
| MD5 |
a3aefe27ef18236d1d987ce7804cdd81
|
|
| BLAKE2b-256 |
987a9e5416b1260fe45b639837d6dcd8382c9db8b2a0719208b1044fa2212b0e
|
File details
Details for the file zenfmt-0.3.3-py3-none-manylinux_2_17_x86_64.whl.
File metadata
- Download URL: zenfmt-0.3.3-py3-none-manylinux_2_17_x86_64.whl
- Upload date:
- Size: 3.1 MB
- Tags: Python 3, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05ee2abaadf7220f729f9ed6f0facd9cfb8641571c4859d6ff197958be48fba2
|
|
| MD5 |
1bc95a390ce329fde81cca7ee9d6e46b
|
|
| BLAKE2b-256 |
5691762ba8480af05dd47cd2eba94ee15cf945dc7abeb1de16b49cd4192ae76c
|
File details
Details for the file zenfmt-0.3.3-py3-none-manylinux_2_17_aarch64.whl.
File metadata
- Download URL: zenfmt-0.3.3-py3-none-manylinux_2_17_aarch64.whl
- Upload date:
- Size: 2.9 MB
- Tags: Python 3, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f254b607de1dd170c4307b49b7976a4e2379383d1336d30c1b1e51921b60e1c
|
|
| MD5 |
c1cbbda1702acd1d07dc033bf26d6cf8
|
|
| BLAKE2b-256 |
51e1cd473ac16ecf57a1ec2092c1ddac6642e9814b84f0d4bef0f2422e622c32
|
File details
Details for the file zenfmt-0.3.3-py3-none-macosx_12_0_x86_64.whl.
File metadata
- Download URL: zenfmt-0.3.3-py3-none-macosx_12_0_x86_64.whl
- Upload date:
- Size: 1.0 MB
- Tags: Python 3, macOS 12.0+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8823df915d60452cc524ee12032c55a9b9e4bd7e90508cfb8994e3aad32c693a
|
|
| MD5 |
2cbfcd9b35f5be34f9776142e48bd958
|
|
| BLAKE2b-256 |
03ef41de70808b9807f3150393a65a13c095bca72d6de4cd8dbbbf3444422ad5
|
File details
Details for the file zenfmt-0.3.3-py3-none-macosx_12_0_arm64.whl.
File metadata
- Download URL: zenfmt-0.3.3-py3-none-macosx_12_0_arm64.whl
- Upload date:
- Size: 951.1 kB
- Tags: Python 3, macOS 12.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43b2d0faaa1abea2224d7b68104cc60b105d0bb65f2becb37ce96ac696f968a9
|
|
| MD5 |
5203369ba80b017cc115b62de507050b
|
|
| BLAKE2b-256 |
811f0900ac834c2bfaa24656f8be143368d7b68c14aed8c8a17a4e85134f7a04
|