Extract PDF Tables to Clean Markdown & JSON for LLMs & RAG
Every tabular export format in one pass
Whether you are pasting a financial schedule into Claude or ChatGPT, indexing tables for a RAG vector store, or feeding a Python ETL pipeline, TableCSV produces all formats from the exact same schema-merged extraction:
| Output Format | Best For | Web App | Python / CLI |
|---|---|---|---|
| GitHub-Flavored Markdown | LLM prompts, RAG chunks, GitHub issues, Notion & docs | One-click Copy Markdown | table.to_markdown() / result.to_markdown() |
| Row-Object JSON | REST APIs, structured LLM tool outputs, ETL pipelines | One-click Copy JSON | table.to_json() / result.to_json() |
| RFC 4180 CSV + Excel BOM | Microsoft Excel, Google Sheets, BI & SQL COPY imports | Download CSV / Copy CSV | table.to_csv() / --utf8-bom |
| ZIP + manifest.json | Multi-table documents with titles, page numbers & schemas | Download All (.ZIP) | result.export_zip() / --zip |
| pandas / polars DataFrame | Python data science, analytics & DuckDB pipelines | Via CSV/JSON export | table.to_dataframe() / table.to_polars() |
Example: GitHub-Flavored Markdown & JSON output
From a 16-page California EDD WARN report (warn_report.pdf), TableCSV merges
all 643 rows across 16 headerless continuation pages in 0.95 s and
renders clean Markdown and JSON ready for LLM ingestion:
| Notice Date | Effective | Company | City | Staff | Type |
| ----------- | ---------- | ------------------------ | ---------- | ----- | ---- |
| 06/22/2015 | 03/25/2016 | Maxim Integrated Product | San Jose | 150 | Clos |
| 06/30/2015 | 08/29/2015 | McGraw-Hill Education | Monterey | 137 | Lay |
[
{
"Notice Date": "06/22/2015",
"Effective": "03/25/2016",
"Received": "07/01/2015",
"Company": "Maxim Integrated Product",
"City": "San Jose",
"No. Of": "150",
"Layoff/Closure": "Closure Permanent"
}
]
Direct Python integration for LLM & RAG pipelines
Call extract_tables() in memory on file paths, raw bytes,
PIL.Image objects, or folders of scans with zero external OS binaries:
from pdf_table_extractor import extract_tables
result = extract_tables("quarterly_filing.pdf")
# Feed all schema-merged tables as Markdown sections into an LLM context window
markdown_context = result.to_markdown()
# Or iterate structured records / DataFrames per logical table
for table in result:
records = table.to_records() # list[dict[str, str]]
json_str = table.to_json() # JSON array of row objects
df = table.to_dataframe() # optional pandas.DataFrame
pl_df = table.to_polars() # optional polars.DataFrame
Frequently asked questions
Why extract PDF tables into Markdown or JSON instead of raw PDF text for RAG?
Naive PDF text extractors flatten multi-column tables into ambiguous line breaks that cause LLMs to mix up adjacent rows and columns. Extracting each table into explicit GitHub-Flavored Markdown pipes or schema-keyed JSON objects preserves exact column-to-value bindings and cuts hallucinated figures in RAG workflows.
Does TableCSV merge tables split across multiple PDF pages into one Markdown or JSON output?
Yes. In default Schema merge mode, TableCSV detects repeated headers and headerless continuation pages across a multi-page PDF, removes duplicate headers, and combines all continuation rows into a single logical table before exporting CSV, Markdown, or JSON.
Can I extract PDF tables directly into Python dicts, pandas, or polars?
Yes. Using the open-source Python package (`pip install pdf-to-csv-table-extractor`), every extracted table exposes `.to_records()`, `.to_columns()`, `.to_markdown()`, `.to_json()`, `.to_dataframe()` (pandas), and `.to_polars()` (polars) without writing temporary CSV files to disk.
Does TableCSV preserve banner titles and flattened stacked headers in JSON?
Yes. Full-width banner titles above tables are promoted to `schema.title` in `manifest.json` and the Python API, while 2-row spanning headers (such as `Percent Fuel Savings` over 4 sub-columns) are flattened into unambiguous column keys so JSON objects never lose parent-group context.