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.1.tar.gz (472.4 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.1-py3-none-win_amd64.whl (1.0 MB view details)

Uploaded Python 3Windows x86-64

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

Uploaded Python 3musllinux: musl 1.2+ x86-64

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

Uploaded Python 3musllinux: musl 1.2+ ARM64

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

Uploaded Python 3manylinux: glibc 2.17+ x86-64

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

Uploaded Python 3manylinux: glibc 2.17+ ARM64

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

Uploaded Python 3macOS 12.0+ x86-64

zenfmt-0.3.1-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.1.tar.gz.

File metadata

  • Download URL: zenfmt-0.3.1.tar.gz
  • Upload date:
  • Size: 472.4 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.1.tar.gz
Algorithm Hash digest
SHA256 ee24dd6b5274a0bcd4d8dd8e7a120baa47b086d71b49e630571f27039b1b0b51
MD5 5f0a58e076e4e67a36f3f68969e84857
BLAKE2b-256 fa264f109e6f8c9c0199860a79e5bc5d1a61393e0bc9161a7e2ccb079953db68

See more details on using hashes here.

File details

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

File metadata

  • Download URL: zenfmt-0.3.1-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.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 dde370323ee463314fac2361dd3c01bb5378fecab1a20cc6d861da319ba29116
MD5 40509bd5a863f7f1d9c9c9654e77113d
BLAKE2b-256 a3e1b6d7c259be1b5813d8449bb44c8cd79c78e62b01b559103e3fa078b7fd56

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zenfmt-0.3.1-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d3a4437d379ac78d46224dbf2fd20cf080cfec937087568d2e9c5ea690d46a0d
MD5 77f07cedf25a618b73261c2c0444dfc6
BLAKE2b-256 cf72e9a842d00acad5ef0ef5133e88f085353cdbd994419845951982d37e3a1b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zenfmt-0.3.1-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 b0bd7114f1faf6b8917854faea8b9d8f66cb0fbe3a0beaaf173c0fcfe3b29f75
MD5 682af0da6abf60d962b68ebbb6f906fc
BLAKE2b-256 577134d2e74b47b40c33dff469bcabc2d6bf4a0e36385d9d04d8c30499a7e94d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zenfmt-0.3.1-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 89f312b41295e0a760b688e4f746b367b12e3efbd66e436b47476bc52f329676
MD5 95f6e1d2d32f2212a700001c77e66317
BLAKE2b-256 dca1de3e46a5fa4f6fb7ca70b7cdee6233445fc2d22cc5e14e00ab261ed75c12

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zenfmt-0.3.1-py3-none-manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 52d8348778bb15ca6c1ed10a3c3348b442a3aa528cec5f071476a9ec601166f1
MD5 defc65065068db5b422116145c7b42a4
BLAKE2b-256 c89c7cb684aa69a3ee5cbefc8febfdd99c2555b4751a4bf968c1bc4eb96a9d09

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zenfmt-0.3.1-py3-none-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 2705721bbdb3883ec336161ffb58c8199cea210e41fb9999f07c217bda49338c
MD5 b30102b205c5c19e82e4e9951fbf649c
BLAKE2b-256 ff79509bc6f054cfaeeb605fdc8203c317879e539be57886bd51f5ad4df5825b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zenfmt-0.3.1-py3-none-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 371fee1dad7ff23cac9f4d28ba037a5e5d3a52be2b5da9a30c1b5ba0c2b02936
MD5 788b7de5cc2cdcf48ddbfe7f82db7ba8
BLAKE2b-256 6b046e0ffbbead335ef78091ca9d161b8dc402c15980ccb94d99c58f7dcd5b51

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