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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3musllinux: musl 1.2+ x86-64

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

Uploaded Python 3musllinux: musl 1.2+ ARM64

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

Uploaded Python 3manylinux: glibc 2.17+ x86-64

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

Uploaded Python 3manylinux: glibc 2.17+ ARM64

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

Uploaded Python 3macOS 12.0+ x86-64

zenfmt-0.3.5-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.5.tar.gz.

File metadata

  • Download URL: zenfmt-0.3.5.tar.gz
  • Upload date:
  • Size: 473.0 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.5.tar.gz
Algorithm Hash digest
SHA256 7c7fa90e6211a7246640418d397fe3c4f8c5deff2365754fa724f3104aa0462b
MD5 8eecda4c01bd228bd851378a0d958b32
BLAKE2b-256 765c74c544badac621f729c5910c9ceacc86864bcabdc3ec72ff75fce675a9a8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: zenfmt-0.3.5-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.5-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 76bfc5d371ee80e913d9c8c6b27902b4b18df2f6faf0e7cdc11cca88573f75be
MD5 55fc92e2173d0cd25cc5673b2b3b69ab
BLAKE2b-256 20fb913a0be5805d3205335ee591e4f3bb1f2a05c45505e3db3302a2dcfafd74

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zenfmt-0.3.5-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 b475880469ddc42630a72e77987cc720f9ff240e68cfa214a0566295e5123a06
MD5 3ecd4b83d0d2e7015c3395b6660c1f31
BLAKE2b-256 4be550200a08603ff4b9556fd3ef7cd45a30a0eeb12b09a7accc0f4e9a15ce2a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zenfmt-0.3.5-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 be9e31ba46684fb71647118c2405bdd779f6acbeb62192f4753b6dd0879533d4
MD5 2cf5651d7b184e6a2801a242c5841fba
BLAKE2b-256 b92d166028ec4de3ecb84431ddcd8e0780f5dbe1c0228d82ec2684817650bd82

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zenfmt-0.3.5-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 c5b55db8786c542c0ed0e40df12118c011b0002dcd9037f0455c2e0952685241
MD5 c4549a97a49f1bd399947af5087c82e9
BLAKE2b-256 0b436e264eb44f0d3970c6e0e377a982077f976c5a1ac80290038aff605b07e6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zenfmt-0.3.5-py3-none-manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 a94d3181588d56ad1112bf2c5ed387823fcd275bc3fc34f002fd1e67abbec581
MD5 49e7f4ff4008b8a9bac5064c72f96e5e
BLAKE2b-256 30e58165b53ac2120cc43fae6b323aae8e43f3e183d122fe89184a18cdbb6fd5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zenfmt-0.3.5-py3-none-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 d9e4bebb46364f7617a34b75419039e8478934b2a29f9d3794689f38eb67a88d
MD5 e6cc269ecd93cae3537476fbafd3d608
BLAKE2b-256 33bcd98515226f1f4e574eca36bb6307fbb7a0111881cd825cefaad3183b1783

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zenfmt-0.3.5-py3-none-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 dcddf830113b5193f6fc3f1a63d1ed22e905c8fbe0afcfbcbe86cd625faef082
MD5 3869b1089e30a8a0e2820e88144b3e3f
BLAKE2b-256 8a9cc565b1f94e785c89178ee541fac79175706b87b6c93fabbb21dbee2e31f0

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 Pingdom Monitoring Sentry Error logging StatusPage Status page