PDF to Markdown: convert text, tables and scanned pages
Convert PDF to Markdown with MarkItDown, PyMuPDF4LLM, Docling or Marker, add OCR for scans, and fix the headers, columns and tables that come out wrong.

To convert PDF to Markdown, use a tool that rebuilds structure from the page layout. For text-based PDFs, markitdown report.pdf -o report.md (MarkItDown) or a few lines of PyMuPDF4LLM give you the text with headings and lists in seconds. For PDFs with tables, columns and figures, Docling and Marker run layout models on your computer and produce cleaner tables, at the cost of a larger install. Scanned PDFs need OCR first, and Pandoc, which handles most other conversions, can't read PDF at all.
The commands below come from each project's own documentation (checked November 2026). All of them run locally; none needs an account.
Why is PDF harder to convert than Word or HTML?
A PDF describes where to draw each character on a page, not what the characters mean. There is no "heading" or "table" in most PDF files, only text at a certain size and position, and lines drawn between some of it. A converter has to guess structure from appearance: large bold text is probably a heading, text aligned in a grid is probably a table, two blocks of text side by side are probably columns.
That guessing is why results differ so much between tools, and why the same tool does well on one PDF and badly on the next. If you have the source document the PDF was made from, convert that instead. A .docx file, for example, converts far more reliably; see Word to Markdown.
Which PDF to Markdown tool should you use?
| Tool | Install | Good at | Watch for |
|---|---|---|---|
| MarkItDown | pip install 'markitdown[pdf]' |
Fast text extraction, one command, MIT license | Its README says it suits text analysis more than faithful conversion; tables are weak |
| PyMuPDF4LLM | pip install pymupdf4llm |
Fast, headings from font sizes, saves images | Built on PyMuPDF, licensed under the AGPL or commercially |
| Docling | pip install docling |
Layout, reading order and tables; OCR on by default | Downloads models on first run; slower |
| Marker | pip install marker-pdf |
Tables, equations and complex layouts | Large install; check its model license before commercial use |
| pdftotext | Part of Poppler (brew install poppler) |
Plain text, very fast | No Markdown structure at all |
A sensible order is to try MarkItDown or PyMuPDF4LLM first, and switch to Docling or Marker only for the PDFs where tables or columns come out wrong.
How do you convert a PDF with MarkItDown?
pip install 'markitdown[pdf]'
markitdown report.pdf -o report.md
MarkItDown also reads Word, PowerPoint, Excel and HTML files with the same command, which helps when a folder holds mixed formats. Install 'markitdown[all]' to enable every format.
How do you convert a PDF with PyMuPDF4LLM?
PyMuPDF4LLM is a Python library, so you run it from a short script:
import pathlib
import pymupdf4llm
markdown = pymupdf4llm.to_markdown("report.pdf", write_images=True, image_path="images")
pathlib.Path("report.md").write_text(markdown, encoding="utf-8")
With write_images=True, images on the pages are saved into the images folder and linked from the Markdown. Leave it out for text only.
How do you convert tables and complex layouts?
Use Docling or Marker. Both detect the parts of each page (headings, paragraphs, tables, figures, captions) with machine learning models that run on your computer, then write them out in reading order.
Docling writes Markdown by default:
pip install docling
docling report.pdf --to md --output converted
Marker writes a folder with the Markdown file and the extracted images:
pip install marker-pdf
marker_single report.pdf --output_dir converted
The first run of each downloads its models, which takes a while and some disk space. Neither needs a GPU, though one makes long documents faster. Marker can optionally send pages to a hosted language model for extra accuracy; that is off unless you configure it.
Even with these tools, check every table against the PDF. Merged header cells and tables that continue across a page break are where errors cluster. If a table is too complex for Markdown's grid, the Markdown tables page explains what pipe tables can and can't hold.
How do you convert a scanned PDF?
A scanned PDF holds pictures of pages, with no text inside. Check by trying to select a sentence in your PDF viewer: if nothing highlights, it's a scan.
You have two options:
- Use a converter with OCR. Docling runs OCR by default, so the Docling command above works on scans as well.
- Add a text layer first, then convert. OCRmyPDF adds searchable text to the PDF itself, and any converter above can then read it:
ocrmypdf -l eng scan.pdf scan-text.pdf
markitdown scan-text.pdf -o scan.md
Use the language code that matches the document (-l deu for German, -l eng+fra for two languages). OCR mistakes look like real words, so proofread names, numbers and dates.
What should you fix after converting?
Every PDF conversion leaves some of the same problems. Work through this list:
- Running headers, footers and page numbers repeated between paragraphs. Search for the document title or "Page" and delete the copies.
- Hyphenated words split across lines, such as
infor- mation. - Columns read in the wrong order, so a paragraph jumps into the middle of another.
- Heading levels guessed from font size. Check that the document has one
#title and that sections step down in order. - Footnotes placed in the middle of the text, at the point where the page ended.
- Equations turned into garbled text. Marker can write LaTeX for them; otherwise retype the important ones using Markdown math syntax.
- Tables with shifted columns, especially in financial and scientific PDFs.
For papers and reports you cite, keep the original PDF next to the Markdown file and link to it at the top of the note, so you can always check a quote against the source. The researchers use case describes one way to organize notes like that.
Common questions
Can Pandoc convert PDF to Markdown?
No. Pandoc reads many formats, including Word, HTML, EPUB and LaTeX, but not PDF. It can write PDF through a PDF engine such as LaTeX or Typst, which is the opposite direction.
Do these tools send the PDF anywhere?
Not in the commands shown here; they all process the file on your computer, apart from downloading models on first use. Some have optional cloud modes. MarkItDown, for example, can send a file to Azure Document Intelligence, a billed service, and Marker can call a hosted language model. Both are off unless you set them up.
How do you convert a folder of PDFs?
Loop over the files in a terminal:
for f in *.pdf; do
markitdown "$f" -o "${f%.pdf}.md"
done
PDF to Markdown in Noteline
Noteline, which we make, does not convert PDFs to Markdown, so use one of the tools above for that step. What it does is keep the two side by side: the desktop app lists PDF files in the sidebar next to your notes and opens them in a built-in viewer in their own tab, so you can read the source in one tab and edit the converted .md file in the next. Tables in the converted file show as an editable grid, which helps when a table needs repairs. Math written in LaTeX is not rendered in the editor; it stays as text.