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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3musllinux: musl 1.2+ x86-64

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

Uploaded Python 3musllinux: musl 1.2+ ARM64

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

Uploaded Python 3manylinux: glibc 2.17+ x86-64

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

Uploaded Python 3manylinux: glibc 2.17+ ARM64

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

Uploaded Python 3macOS 12.0+ x86-64

zenfmt-0.3.0-py3-none-macosx_12_0_arm64.whl (951.2 kB view details)

Uploaded Python 3macOS 12.0+ ARM64

File details

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

File metadata

  • Download URL: zenfmt-0.3.0.tar.gz
  • Upload date:
  • Size: 471.9 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.0.tar.gz
Algorithm Hash digest
SHA256 b2982a2d56eea750f545ec51236eba46290528e56faceab92facbedde1f7eb50
MD5 d96621bcefe71a842b626d8d267f87b8
BLAKE2b-256 68005674b3a8185b9e7ae06b1f98e49c8f65bd01ac9fb7894adcb3c1e02b0838

See more details on using hashes here.

File details

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

File metadata

  • Download URL: zenfmt-0.3.0-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.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 c5dfeffaaa065eb4d8af6c406314dbaa735d000680e7bfb192873d77895111a5
MD5 bc29f66fa63ae88fd78796579e754468
BLAKE2b-256 e4c29a563b30c264fd29b5bd7cd39382072de5f3fb525db94fe662dcf26c9da2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zenfmt-0.3.0-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 34ed9e0a489a65308ab576536928f104178c8307f9b060eb91f2d68e7d8cb559
MD5 09033dc863a2f289ca1dcbbf76f3e11a
BLAKE2b-256 38117df68b9cca89b91046d395113d6d1c99b902c45b04dc5213b01b2014f922

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zenfmt-0.3.0-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 7ee59ce501739d55e009878e97b287170ebd5c66fafa3ac6eb0dbfab326dd52d
MD5 2855bc5996728c94fa3a9a5978edefc5
BLAKE2b-256 cd03de891e1ef0ec5cffed73f44a495db3364a8a6ca4b7c34fb0c0443f7f0ee4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zenfmt-0.3.0-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 8c203279fc54445444e4fa043b8db69ac76ef532c02b612a35eeb400d617c22f
MD5 5643eac73910da8992e926b0ea1213d3
BLAKE2b-256 a673defc83e9df01a9b1bc964c7eae1655a9831da73587e36722d6ca5b2e0c6a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zenfmt-0.3.0-py3-none-manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 f8e876d014f25773f84cecf873b884c361642a9ff366988bd17f95b67cb52d4c
MD5 76eac73b7e3c4cd9f67e47e781bc7c26
BLAKE2b-256 c1a32018debca7a13fd6d2c9977c2c57c12dbae56d74f0b2702e394b016f047d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zenfmt-0.3.0-py3-none-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 774c88a4e15e6acae9c9b6c5f5f669c7408b3e10cd49676078bba36b457defc3
MD5 9b6359247e4712f6d538035ff82b0e32
BLAKE2b-256 8468324781580558688bdc205a818e6531587b6f070e435f86d8e87501fd5e9e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zenfmt-0.3.0-py3-none-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 6c00d421a8daa3444f6f981f0f185edf130ea55e948214a072a089fd5fee7eca
MD5 168f855dbb9bd95ad3d3add0c1d60c85
BLAKE2b-256 1266c7998af3294a0526537e402e4fe33a6e5e13c37dd960f6ebf90c19771009

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