Convert PDFs to clean, structured Markdown in one command. Built for the AI age, where feeding documents to LLMs means getting them out of PDF and into a format models can actually work with.
uv tool install git+https://github.com/mrgeoffrich/pdf2md-cli.gitThis installs pdf2md as an isolated CLI tool. Or run it directly without installing:
uvx --from git+https://github.com/mrgeoffrich/pdf2md-cli.git pdf2md input.pdfRequires Python 3.10+.
pip install git+https://github.com/mrgeoffrich/pdf2md-cli.gitPre-built binaries for Linux, macOS, and Windows are available on the releases page.
pdf2md input.pdf # Output to stdout
pdf2md input.pdf -o output.md # Output to file
pdf2md input.pdf -p 1-5 # Convert specific pages
pdf2md input.pdf -p 1,3,7-10 # Convert selected pages
pdf2md input.pdf --images --image-dir img # Extract images to files
pdf2md input.pdf --embed-images # Embed images as base64
pdf2md input.pdf --page-breaks # Insert --- between pages
pdf2md input.pdf --max-header-level 2 # Clamp headings to h2
pdf2md input.pdf --keep-headers-footers # Preserve running headers/footers
pdf2md input.pdf -v # Verbose loggingBy default, pdf2md strips running headers, footers, and page numbers. Use --keep-headers-footers to preserve them.
| Option | Description |
|---|---|
-o, --output PATH |
Write to file instead of stdout |
-p, --pages RANGE |
Page range (e.g. 1-5, 1,3,7-10) |
--images / --no-images |
Extract images to files |
--embed-images |
Embed images as base64 in markdown |
--image-dir DIR |
Directory for extracted images (default: ./images) |
--image-format {png,jpg} |
Image format (default: png) |
--dpi N |
DPI for image extraction (default: 150) |
--page-breaks |
Insert --- between pages |
--max-header-level N |
Limit heading depth, 1-6 (default: 6) |
--keep-headers-footers |
Keep running headers/footers (stripped by default) |
-v, --verbose |
Verbose logging |
--version |
Show version |
uv sync --extra dev
uv run pytest -v
uv run ruff check .
uv run ruff format .Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT License.