How do you extract tables from a PDF URL?
To extract tables from a PDF URL, pass the URL to a parser that can fetch the document and interpret its visual layout into rows and columns. For text-based PDFs with consistent formatting, rule-based libraries like pdfplumber or camelot work well; for scanned documents or variable layouts, LLM-based extraction handles the structure more reliably. Tables in PDFs have no underlying markup like HTML tables do: they are drawn using lines, whitespace, and positioned text, so parsers have to infer structure from layout rather than read it from tags.
| Factor | Rule-based tools (pdfplumber, camelot) | LLM-based extraction |
|---|---|---|
| Setup | Install locally, configure per document | API call |
| Scanned PDFs | No | Yes, with OCR |
| Inconsistent layouts | Breaks | Adapts per document |
| Output format | Raw text or CSV | Markdown, JSON via schema |
| Maintenance | Breaks on PDF updates | None |
Use rule-based parsers for machine-generated PDFs with rigid, predictable structure (financial exports, data extracts). For research papers, government filings, or any document where table formatting varies, LLM-based extraction is more reliable.
For web-hosted PDF URLs, Firecrawl's web scraping service with document parsing returns tables as structured Markdown with no download required, or as JSON rows when you pass a schema:
from firecrawl import Firecrawl
firecrawl = Firecrawl(api_key="fc-YOUR-API-KEY")
doc = firecrawl.scrape(
"https://github.com/camelot-dev/camelot/raw/master/docs/_static/pdf/foo.pdf",
formats=[{
"type": "json",
"prompt": "Extract every row of the table as one object per row.",
"schema": {
"type": "object",
"properties": {
"rows": {
"type": "array",
"items": {
"type": "object",
"properties": {
"cycle_name": {"type": "string"},
"distance_mi": {"type": "number"},
},
"required": ["cycle_name", "distance_mi"],
},
},
},
"required": ["rows"],
},
}],
)
print(doc.json)
# {'rows': [{'cycle_name': '2012_2', 'distance_mi': 1.3}, ...]}For local or non-public documents, the /parse endpoint accepts the file directly and produces the same output. Combine it with schema-based extraction to pull specific table fields into a typed output without writing layout rules. For scanned sources, the ocr mode handles image-based pages before parsing. The underlying document extraction engine, Fire-PDF, allocates higher token limits specifically to table regions and allows up to 25 seconds for accurate markdown table output, which is especially useful for financial reports and dense multi-column filings where table structure varies across documents. For a comparison of AI PDF parsers and how they handle table extraction across different document types, see the best PDF parsers guide. For a broader evaluation of managed document parsing APIs, including which one returns PDF tables as JSON, see the best document parsing APIs guide.