Convert PDF, DOCX, CSV, and image files to Markdown.
Project description
documint2md
Convert PDF, DOCX, CSV, and image files to Markdown from the command line or from Python.
documint2md installs the doc2md CLI and the doc2md Python package. It is designed for scripts, agents, and documentation pipelines that need predictable Markdown output and clear machine-readable status.
Install
python -m pip install documint2md
Optional extras:
python -m pip install "documint2md[markdown]" # GFM Markdown formatting
python -m pip install "documint2md[pymupdf4llm]" # alternate PDF Markdown engine
python -m pip install "documint2md[universal-lite]" # MarkItDown for extra formats
python -m pip install "documint2md[docling]" # Docling structured conversion
python -m pip install "documint2md[ocr]" # image and scanned-PDF OCR
python -m pip install "documint2md[all]" # all published optional features
Python 3.11 or newer is required.
Command Line
Convert one file and write <input stem>.md beside it:
doc2md report.pdf
doc2md notes.docx
doc2md table.csv
doc2md scan.png
Choose an output path:
doc2md report.pdf -o report.md
Write Markdown to stdout:
doc2md report.pdf -o -
Preview without writing a file:
doc2md report.pdf --preview
Run several inputs non-interactively:
doc2md docs/*.pdf --yes
Open the interactive picker:
doc2md
Agent and Automation Usage
Use --json when another program needs a structured result. Diagnostics still go to stderr, and stdout stays reserved for JSON in this mode.
doc2md report.pdf --json
doc2md report.pdf --dry-run --json
Useful automation flags:
doc2md report.pdf --quiet
doc2md report.pdf --debug
doc2md report.pdf --stats
doc2md doctor engines --json
Exit codes:
0: success2: usage or argument error3: unsupported format4: conversion failed5: output write failed
Output behavior:
- By default,
report.pdfwritesreport.mdin the same directory. -o <file>writes UTF-8 Markdown with\nnewlines.-o -writes Markdown to stdout.- Errors and diagnostics go to stderr.
Formats and Engines
Default conversions:
- PDF: text extraction with
pdfminer.six - DOCX: Mammoth HTML to Markdown
- CSV: Pandas to Markdown table
- Images: OCR when the
ocrextra is installed
Force a format:
doc2md input.bin --format pdf
doc2md input.bin --format docx
doc2md input.bin --format csv
doc2md input.bin --format image
Use optional engines:
doc2md report.pdf --engine pymupdf4llm
doc2md slides.pptx --format any --engine markitdown
doc2md document.docx --format any --engine docling
Check installed optional engines:
doc2md doctor engines
doc2md doctor engines --json
Markdown Formatting
Every CLI conversion can post-process Markdown:
doc2md table.csv --md-style normalize
doc2md table.csv --md-style gfm
doc2md table.csv --md-style none
normalizeis the default. It normalizes newlines, strips trailing whitespace, caps blank lines, and ends non-empty output with one trailing newline.gfmformats GitHub Flavored Markdown and requiresdocumint2md[markdown].noneleaves converter output unchanged after conversion.
OCR
Install OCR support:
python -m pip install "documint2md[ocr]"
Convert an image:
doc2md scan.png --ocr-lang en
Use OCR for scanned or low-text PDFs:
doc2md scan.pdf --ocr-mode auto --ocr-lang en
doc2md scan.pdf --ocr-mode always --ocr-layout heuristic --md-style gfm
Common OCR options:
doc2md scan.pdf --ocr-device cpu
doc2md scan.pdf --ocr-device gpu:0
doc2md scan.pdf --ocr-render-scale 2.0
doc2md scan.pdf --ocr-min-score 0.5
doc2md scan.pdf --ocr-debug-json debug.json
doc2md scan.png --ocr-debug-image debug.png
The first OCR run may download model files for the OCR backend. Subsequent runs are normally faster.
Python API
from doc2md import (
any_to_markdown,
csv_to_markdown,
docx_to_markdown,
image_to_markdown,
pdf_to_markdown,
)
markdown = pdf_to_markdown("report.pdf")
Each public converter accepts str or PathLike input and returns str.
from doc2md import ConversionError, UnsupportedFormatError, pdf_to_markdown
try:
markdown = pdf_to_markdown("report.pdf")
except UnsupportedFormatError as exc:
print(f"Unsupported input: {exc}")
except ConversionError as exc:
print(f"Conversion failed: {exc}")
Profiles
Store reusable defaults in doc2md.toml:
[profiles.fast_pdf]
format = "pdf"
engine = "pdfminer"
md_style = "normalize"
[profiles.ocr_pdf]
format = "pdf"
ocr_mode = "auto"
ocr_lang = "en"
ocr_layout = "heuristic"
md_style = "gfm"
Run with a profile:
doc2md report.pdf --profile fast_pdf
doc2md scan.pdf --profile ocr_pdf
Notes for Reliable Automation
- Pin the package version in production, for example
documint2md==2.0.2. - Use
--jsonfor structured status and-o -only when stdout should contain Markdown. - Use
--yesfor batch conversions in non-interactive jobs. - Use
--md-style normalizeor--md-style gfmwhen exact Markdown formatting matters. - Run
doc2md doctor engines --jsonin setup checks to confirm optional engines are installed.
Links
- PyPI project: https://pypi.org/project/documint2md/
- Source repository: https://github.com/myucordero/documint2md
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file documint2md-2.0.2.tar.gz.
File metadata
- Download URL: documint2md-2.0.2.tar.gz
- Upload date:
- Size: 74.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d4371c4678887167758a8f496d26353fa73589991ed71336cbf919cfa447bc0
|
|
| MD5 |
bcc6c8ea5efe1fdfc0b3c5b798b3d2fd
|
|
| BLAKE2b-256 |
7dab20e624c8f30e3e5d52abaf35b037d5766be4ae8171dfa3cbac28967bf9e2
|
Provenance
The following attestation bundles were made for documint2md-2.0.2.tar.gz:
Publisher:
release-pypi.yml on myucordero/documint2md
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
documint2md-2.0.2.tar.gz -
Subject digest:
7d4371c4678887167758a8f496d26353fa73589991ed71336cbf919cfa447bc0 - Sigstore transparency entry: 1781258635
- Sigstore integration time:
-
Permalink:
myucordero/documint2md@f33d9655cfc56db0bef17adcff0fe42be2f020dc -
Branch / Tag:
refs/tags/v2.0.2 - Owner: https://github.com/myucordero
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@f33d9655cfc56db0bef17adcff0fe42be2f020dc -
Trigger Event:
push
-
Statement type:
File details
Details for the file documint2md-2.0.2-py3-none-any.whl.
File metadata
- Download URL: documint2md-2.0.2-py3-none-any.whl
- Upload date:
- Size: 52.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
884d00e8794d5246826370910502d237daee7728200f7963168ca19a2c00c0ca
|
|
| MD5 |
dafc01fc70d8a1baf688d072d3961827
|
|
| BLAKE2b-256 |
185f31ea0cf986db8bb2e4aef024f68353f7e5eba6db71825cdb197ba91f6302
|
Provenance
The following attestation bundles were made for documint2md-2.0.2-py3-none-any.whl:
Publisher:
release-pypi.yml on myucordero/documint2md
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
documint2md-2.0.2-py3-none-any.whl -
Subject digest:
884d00e8794d5246826370910502d237daee7728200f7963168ca19a2c00c0ca - Sigstore transparency entry: 1781258754
- Sigstore integration time:
-
Permalink:
myucordero/documint2md@f33d9655cfc56db0bef17adcff0fe42be2f020dc -
Branch / Tag:
refs/tags/v2.0.2 - Owner: https://github.com/myucordero
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@f33d9655cfc56db0bef17adcff0fe42be2f020dc -
Trigger Event:
push
-
Statement type: