pypandoc

Thin Python wrapper around Pandoc for converting documents between formats

Library
PyPI
v1.17
1,151stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
66/100Good
Development Activity64
Maintenance36
Community76
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
80/100Excellent
Architecture80
Code Quality78
Innovation76
Learning Curve88

pypandoc is a lightweight Python wrapper around the Pandoc universal document converter. It exposes simple functions to convert strings or files between dozens of markup and document formats, including Markdown, reStructuredText, HTML, LaTeX, DOCX, EPUB, and PDF, while letting you pass through any extra Pandoc arguments and filters.

The library handles locating an installed Pandoc binary, can download a matching Pandoc build for your platform on demand, and validates input and output formats before invoking the tool. This makes it a convenient bridge for Python applications that need reliable, high-fidelity document conversion without shelling out to Pandoc by hand.

What You Get

  • convert_text and convert_file functions for one-call conversion between formats
  • Support for the full range of Pandoc input and output formats (Markdown, HTML, LaTeX, DOCX, EPUB, PDF, and more)
  • Pass-through of arbitrary Pandoc extra arguments and Pandoc/Lua filters
  • Automatic discovery of an installed Pandoc binary, plus on-demand download of a matching build
  • Format verification helpers and a small command-line entry point

Common Use Cases

  • Converting Markdown content to HTML or PDF inside a Python application
  • Generating DOCX or EPUB documents from structured source text
  • Applying Pandoc filters to transform documents programmatically
  • Bundling document conversion into a pipeline without requiring users to pre-install Pandoc

Under The Hood

Architecture - pypandoc is a single Python package whose init.py exposes the public convert_text/convert_file/get_pandoc_formats API and orchestrates conversions by building a Pandoc command line and running it via subprocess. Supporting modules handle concerns cleanly: pandoc_download.py locates or downloads a Pandoc build, handler.py manages logging, and cli.py/_cli.py provide the command-line entry point.

Tech Stack - Pure Python (targeting 3.7 through 3.15 on both CPython and PyPy) with no required runtime dependencies beyond the standard library; the actual conversion work is delegated to the external Pandoc binary. Packaging uses a modern pyproject.toml with a uv lockfile, and an optional tinytex extra pulls in pytinytex for PDF output.

Code Quality - The codebase is small and typed with function annotations, and ships a tests directory with test_data fixtures plus a filter test. Being a thin wrapper, most correctness concerns are about argument construction and format validation, which the library checks before invoking Pandoc.

API Design - The API is intentionally minimal and discoverable: two primary conversion functions with sensible keyword arguments (to, format, extra_args, filters, outputfile), plus helpers to query supported formats and manage the Pandoc binary. This keeps the common case trivial while exposing Pandoc’s full power through extra_args.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search