pypandoc
Thin Python wrapper around Pandoc for converting documents between formats
Repository Health
Technical Analysis
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.
Used by 2 apps in this directory
Open WebUI
AI Assistants · AI Agents
The extensible, privacy-first AI platform that runs Ollama, OpenAI, and any LLM backend behind a polished, feature-packed web interface.
SurfSense
Search · AI Assistants
The open-source, unlimited NotebookLM alternative with real-time collaboration, a desktop app, and no vendor lock-in.