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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3musllinux: musl 1.2+ x86-64

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

Uploaded Python 3musllinux: musl 1.2+ ARM64

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

Uploaded Python 3manylinux: glibc 2.17+ x86-64

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

Uploaded Python 3manylinux: glibc 2.17+ ARM64

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

Uploaded Python 3macOS 12.0+ x86-64

zenfmt-0.2.0-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.2.0.tar.gz.

File metadata

  • Download URL: zenfmt-0.2.0.tar.gz
  • Upload date:
  • Size: 467.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for zenfmt-0.2.0.tar.gz
Algorithm Hash digest
SHA256 3d39fe729b177292b6326a7c816df977514090a87148c2f32d7eb9322cf5fb5d
MD5 5dc0943a974f911772c024c5c7311e1e
BLAKE2b-256 f7240b969069752d4bd6b5a0e146e1cd1aedb04f6551499a52f09282afa7230d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: zenfmt-0.2.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.2.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 70294ecf0c1b22f8f3beea4215f28eb757f5d2d9062ac7ef69876d141d7d2faa
MD5 1b57df7e5ed7224b0a22b7b2a190f9b4
BLAKE2b-256 3acd7bba42ab1b3e9fbf9cb132e82e1c772224f5849128fa03710904141761e0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zenfmt-0.2.0-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 06663d7995c40b99a5cdd6cfa344bb20aad85f79a5b25c39c58b51a858d5f5e5
MD5 74022843699aadc270b5c7f3560d25d4
BLAKE2b-256 9ec74248c098f77cf34e4024143b73b6b05d4b5e44d5504b109217c09b64a1da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zenfmt-0.2.0-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 9959fd16441dab085bf36f4bbfd454f53f1517d0df2b7a9ff0725a18f01eadcb
MD5 47c80587ae48f79e40753b764a41c1e4
BLAKE2b-256 a1c08a73d7904533e2ff2be89ae9d32219e5c0343f8623c72b764b3e3e127e80

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zenfmt-0.2.0-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 8aac84d4c0c28a368a0345f13c24d10044f5e4d86950e6d40779b1ba379f8c09
MD5 f4b1182ad6f1f05ad88327a961388e90
BLAKE2b-256 4ad3585d75322b4f40b375300f7855cc377b0f1d55c72281f49b5ceec00ebcd7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zenfmt-0.2.0-py3-none-manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 b807441e5f1e471c5b3c05c98c53d0a6633d5845789debb70ac188c921f7ac61
MD5 2860631ae42f9b37ec3959a917e3ee5a
BLAKE2b-256 5233aea8895220f23fca0d11e1a8681a5f1e65da3648fe15a15e93a9ae89c16b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zenfmt-0.2.0-py3-none-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 2fbf2d71bc04723f153b91c54af00c0caf8166290e10f751d2d5a9a8f756b6af
MD5 3b552e4eb96f2e8c925f763807c1e059
BLAKE2b-256 fe559eca804e7fbf58835a3bf4b89d19d8ab87a966123cbbac289026a0497784

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zenfmt-0.2.0-py3-none-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 2de0728f75bef344246fcaa225c58c9c6c67e28669dbbc8109d3d6bcc3ea822c
MD5 9c8ebb177da0d34375cad474599b581e
BLAKE2b-256 24302b3f0b826cc789f6f812f8a1965aee2d0fa6ca0f043f28bffc28cd76dcff

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