Home / Guides / How to Extract Tables from a PDF

Updated

How to Extract Tables from a PDF (Measured on a Real Paper)

To extract tables from a PDF you can use a free Python library such as pdfplumber, Camelot or Tabula, or a ready-made converter that returns every table as rows. On a 15-page paper with 4 borderless tables, pdfplumber's default settings found 2 of the 4 tables, collapsed both into a single column and reported 8 false tables in figures, while Plainprobe Document to Markdown returned the 4 tables with their columns in 2.3 seconds.

The test: one real PDF, two methods

We used the paper Attention Is All You Need (arXiv 1706.03762, 15 pages). It contains 4 tables, on pages 6, 8, 9 and 10, drawn without vertical lines, as in most papers and reports. Measured on 4 December 2026.

MethodReal tables foundColumns keptFalse tablesTime
pdfplumber 0.11.11, default settings2 of 4 (pages 9 and 10)No: each row in 1 cell8 (figures on pages 13 to 15)1.9 s locally
pdfplumber, text strategytable-like blocks on all 15 pagesPartlyMany: every page has one2.5 s locally
Plainprobe Document to Markdown4 of 4 (pages 6, 8, 9, 10)Yes (4 to 12 columns)02.3 s conversion, 7 s whole run

One PDF is not a benchmark of every layout: test on your own documents before choosing.

Option 1: pdfplumber in Python

Free and precise when tables have ruling lines:

import pdfplumber
with pdfplumber.open("report.pdf") as pdf:
    for page in pdf.pages:
        for table in page.extract_tables():
            print(page.page_number, table[:3])

For borderless tables, try page.extract_tables({"vertical_strategy": "text", "horizontal_strategy": "text"}), then filter out the blocks that are really paragraphs or figures. Camelot (stream mode) and Tabula offer similar choices.

Option 2: a converter that returns tables as rows

Plainprobe Document to Markdown takes the URL of a PDF, DOCX, PPTX or HTML file and returns the whole document as Markdown, with every table as a Markdown pipe table and, per page, as a list of rows ready for pandas or a spreadsheet. It costs $0.004 per document (first 50 pages included); failed documents are free.

Pitfalls to check whatever you use

FAQ

Can I extract tables from a PDF for free?

Yes. Python libraries such as pdfplumber, Camelot or Tabula are free. They work best on tables drawn with ruling lines; on borderless tables (common in papers and reports) check the result, because tables can be missed or merged into one column.

Why does my PDF table come out as one column?

Most PDFs store text as positioned words, not as a table. A tool that only follows drawn lines sees no column borders on a borderless table and returns each row as a single cell. Use a word-position (text) strategy, or a converter that rebuilds columns from word positions.

Can I get the tables as JSON or CSV?

Yes. Convert the PDF to Markdown pipe tables or to a list of rows, then load the rows into pandas or a spreadsheet; each row becomes a list of cell strings.

What about scanned PDFs?

A scanned page is an image: it needs OCR first. Text recognition errors then flow into the table, so check numbers on scans by hand.

Related tool