Web Scraping
Arslan
ArslanAug 13, 2026

Learn how to extract tables from PDF files using copy-paste, free tools, Python, OCR, LLMs, and APIs, with options for Excel, CSV, and JSON output.

How to Extract Tables From PDF: 6 Methods That Work

PDF table extraction means detecting a table inside a PDF document and converting it into a structured format your systems can use—Excel, CSV, or JSON. The process pairs table detection (finding where a table starts and ends) with reading the cell contents into rows and columns.

Several methods exist, from free drag-and-drop tools to Python libraries to APIs. The right choice depends on whether you need a one-off export or automated extraction in a data pipeline. According to a 2023 IDC white paper, 90% of the data generated by organizations was unstructured, and global organizations were predicted to generate over 73,000 exabytes of unstructured data in 2023 alone. Much of that data lives in PDFs—and the tables locked inside them are often exactly the records teams need.

Why Are Tables in PDFs So Hard to Extract?

A PDF is a set of instructions for drawing characters at fixed positions on a page—it has no semantic concept of "this is a table" or "this is a header." The format stores where characters appear, not what they mean. That is why simple copy-paste often scrambles rows and columns: the PDF contains layout coordinates, not cell relationships.

Reading order can also be ambiguous. A two-column financial report, for example, may list left-column values before right-column values in the file's internal order, even though a human reads across the row. Without explicit table structure, software must infer where one cell ends and another begins based on whitespace and alignment alone.

Text-Based PDFs vs Scanned PDFs

Understanding the difference between text-based and scanned PDFs is essential before choosing an extraction method.

PDF TypeContainsExtraction Approach
Text-based (digital)Selectable, embedded textTools read text directly; no OCR needed
ScannedImage of the page; no text layerOCR must run first to convert pixels to characters
MixedSome pages text, some scannedExtraction must detect and handle both

Text-based PDFs are created digitally—exported from Excel, Word, or a reporting tool. You can highlight and copy text. Extraction tools read this text layer directly.

Scanned PDFs are images of printed pages. There is no text to select. Extracting data requires OCR (Optical Character Recognition), a technology that converts an image of text into machine-readable characters. Many real-world documents—bank statements, older contracts, faxed invoices—are scans.

Methods to Extract Tables From a PDF

The right method depends on your document type (text-based vs scanned), the volume of files, and whether you need repeatable automation. Below are six approaches, from manual to fully automated.

Method 1: Copy-Paste (and Why It Usually Fails)

Copy-paste is the fastest option for a single table. Select the table region in your PDF reader, copy, and paste into Excel or Google Sheets.

Why it breaks: PDFs store character positions, not table structure. When you paste, cells often collide, shift columns, or merge into a single line. This approach works only for tiny, simple tables with no merged cells and clear borders—and even then, you will likely need manual cleanup.

Method 2: Free Online Tools and Desktop Apps

Point-and-click tools convert PDF tables to Excel or CSV without code. Examples include:

  • Tabula (free, open-source): Works well on text-based PDFs with clear table borders.
  • PDF-to-Excel converters: Adobe Acrobat, Smallpdf, and others export to spreadsheet formats.
  • OCR web tools: Services like Nanonets or online OCR converters handle scanned files.

Best for: One-off extractions when you need a quick result and do not require automation.

Limitations:

  • Manual process—not repeatable at volume.
  • Many free tools struggle with complex tables (merged cells, multi-level headers).
  • Scanned-PDF support varies; some tools require a paid tier for OCR.

Method 3: Python Libraries (Camelot, pdfplumber, PyMuPDF)

Developers automating extraction often reach for Python libraries. Three popular options:

  • Key point: Camelot uses two detection modes—lattice (bordered tables with lines) and stream (borderless tables inferred from whitespace).
  • Key point: pdfplumber extracts tables with fine control over bounding boxes and can output to pandas DataFrames.
  • Key point: PyMuPDF reads tables and also handles text, images, and annotations.

These libraries read text-based PDFs. They do not handle scanned PDFs out of the box—you need a separate OCR step (e.g., Tesseract) before passing text to them.

Example with pdfplumber:

python
import pdfplumber

with pdfplumber.open("report.pdf") as pdf:
    page = pdf.pages[0]
    table = page.extract_table()
    for row in table:
        print(row)

This snippet opens a PDF, extracts the first table on page one, and prints each row as a list of cell values.

Method 4: OCR and AI Tools for Scanned PDFs

When the PDF is a scan or an image, OCR converts pixels into text. AI layout models then reconstruct rows and columns by analyzing spacing, lines, and alignment.

Accuracy depends on scan quality. A resolution of at least 300 DPI produces reliable results; low-quality scans with skewed pages or faded text increase errors. Modern AI/OCR tools—including cloud services and specialized document-processing platforms—generally outperform rule-based libraries on scanned files and complex layouts.

Method 5: LLM-Based Extraction

Large language models (LLMs) can interpret a PDF's text—or an image of a table—and return structured JSON matching a schema you define. This approach excels on messy, borderless "fake" tables where visual cues are ambiguous.

Key point: LLMs are strong at fuzzy interpretation but can hallucinate values, especially on empty or ambiguous cells.

For production workflows, combine LLM extraction with deterministic parsing rather than relying on the model alone. Use rule-based tools for stable, well-structured fields (invoice numbers, dates) and LLMs for free-form or inconsistent sections.

Method 6: API-Based Extraction at Scale

An API removes the need to maintain your own OCR engines, parsing libraries, and infrastructure. You call an endpoint with a PDF URL; the service handles detection, extraction, and formatting.

How an API like Olostep works:

  1. Point it at a PDF URL.
  2. The service auto-detects the PDF and extracts text with layout preserved.
  3. If the file is scanned, OCR runs automatically.
  4. Detected tables convert to markdown or schema-based JSON.
  5. A maxPages option lets you control cost by limiting how many pages to process.

This happens in one API call. For developers, it means no juggling separate OCR services, no debugging parser edge cases, and no maintaining browser or proxy infrastructure. Learn more about how to scrape and parse PDFs via the scrape endpoint.

How to Choose the Right Extraction Method

Selecting the right approach saves time and avoids rework. Use the decision matrix below to match your situation to a method.

MethodBest ForHandles Scanned PDFs?OutputEffort / Scale
Copy-PasteSingle simple tableNoClipboardMinimal / one-off
Free Tools (Tabula, converters)One-off exports, non-technical usersVaries (often no)Excel, CSVLow / manual
Python LibrariesDevelopers, text-based PDFsNo (requires separate OCR)DataFrame, CSV, JSONMedium / scriptable
OCR/AI ToolsScanned PDFs, complex layoutsYesVariesMedium / per-document
LLM ExtractionMessy tables, schema inferenceYes (via image input)JSONMedium / needs validation
API (e.g., Olostep)High volume, automation, production pipelinesYes (built-in OCR)Markdown, JSONLow / batches of 10k URLs

When automation pays off: Manual methods become costly at volume. According to Ardent Partners' 2024 research, companies without best-in-class automation pay an average of $12.88 to process a single invoice and take an average of 17.4 days to do so. For recurring extraction tasks—monthly reports, invoice processing, data migrations—an API or scriptable pipeline quickly delivers ROI.

Extracting PDF Tables as Structured JSON at Scale

Production pipelines need clean, structured output—not text blobs that require manual parsing. Schema-based extraction solves this.

Define a schema (the fields matching your table columns), and the extraction service returns rows as JSON arrays. Each row preserves column relationships, and the output conforms to a predictable structure your downstream systems can consume directly.

Example schema output:

json
{
  "table": [
    {"date": "2026-01-15", "description": "Consulting", "amount": 4500.00},
    {"date": "2026-01-22", "description": "License fee", "amount": 1200.00}
  ]
}

With schema-based extraction, you define fields once, and every document returns the same JSON contract. Prebuilt parsers handle common sources; custom parsers cover domain-specific formats.

For high volumes, batch processing runs up to 10,000 URLs per job in minutes. Treat parser output as a stable JSON contract for RAG pipelines, AI agents, and database ingestion. Olostep's web scraping API combines deterministic parsers for stable fields with LLM extraction for fuzzy fields—giving you structured reliability without sacrificing flexibility.

Best Practices for Accurate Table Extraction

Extraction is only valuable if the output is correct. Garbage data downstream costs more than time spent validating.

Validate output:

  • Check row and column counts against the source.
  • Verify totals and sums match.
  • Confirm data types (dates parse as dates, numbers as numbers).
  • Spot-check low-confidence values.

Handle multi-page tables: Tables that span pages require stitching. Ensure your tool or script carries headers forward and joins rows across page breaks.

Normalize after extraction: Trim whitespace, standardize date formats, and map inconsistent labels to canonical values before loading data into production systems.

Accuracy matters: A 2025 report from the IBM Institute for Business Value found that 43% of chief operations officers cite data quality as their most significant data priority. And a 2025 systematic review pooled 93 clinical research studies and found that manual document abstraction—reading a source and keying data by hand—carried a pooled error rate of 6.57%, versus just 0.14% for double-entry verification. The underlying task is the same one at work when someone copies table data from a PDF into a spreadsheet. Automated extraction with validation catches errors before they propagate.

Combine deterministic and AI extraction: Use rule-based parsers for structured, predictable fields. Reserve LLMs for free-form content or edge cases where rigid rules fail. This hybrid approach maximizes accuracy while handling real-world document messiness.

Frequently Asked Questions

Can I Extract Tables From a Scanned PDF?

Yes, but a scanned PDF is an image with no text layer. OCR must run first to convert the scan into text, and then the table structure is reconstructed from the recognized characters.

How Do I Extract a Table From PDF Into Excel?

Use a PDF-to-Excel tool, Python library, or API that preserves table structure. The key is ensuring rows and columns map correctly into spreadsheet cells rather than collapsing into a single column.

Can I Extract Tables From a PDF in Python?

Yes. Camelot and pdfplumber handle text-based PDFs directly. For scanned files, run OCR (e.g., Tesseract) first, then pass the text to a parsing library. Output to DataFrame, CSV, or JSON.

Why Does Copy-Paste Break PDF Tables?

PDFs store character positions, not table structure. When you paste, the software has no information about cell boundaries, so values lose their row and column alignment.

What Is the Best Way to Extract Tables From PDFs at Scale?

An API that auto-detects PDFs, runs OCR when needed, and returns structured JSON is the lowest-maintenance path for high volumes, removing the need to maintain parsing libraries or stitch tools together. This mirrors a broader shift: the U.S. Bureau of Labor Statistics projects a 26% decline in data entry keyer employment between 2024 and 2034 as automation replaces manual document processing.

About the Author

Arslan Ali

Co-Founder, Olostep · San Francisco, CA

Arslan is the co-founder of Olostep, a web data infrastructure platform that helps developers and teams access, extract, and structure web data at scale. He works closely on the product and technology behind Olostep, with a focus on building reliable infrastructure for web scraping, search APIs, and structured web data.

Read more