> ## Documentation Index
> Fetch the complete documentation index at: https://pdfbase.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Extract tables

> Extract structured table data from PDFs as JSON or CSV.

## Phase

**Phase 3** — Ships only if \$1K+ MRR. Combines layout analysis + AI extraction.

## Request

<ParamField body="source" type="object" required>
  The PDF to extract tables from.
</ParamField>

<ParamField body="pages" type="string" default="all">
  Pages to scan for tables.
</ParamField>

<ParamField body="format" type="string" default="json">
  Output format: `json` or `csv`.
</ParamField>

<ParamField body="use_ocr" type="boolean" default="false">
  Run OCR before table detection. Required for scanned documents.
</ParamField>

## Response

```json theme={null}
{
  "id": "ext_tables1",
  "object": "extraction",
  "status": "completed",
  "tables": [
    {
      "page": 1,
      "index": 0,
      "rows": 5,
      "columns": 4,
      "headers": ["Item", "Qty", "Unit Price", "Total"],
      "data": [
        ["Widget Pro", "10", "$50.00", "$500.00"],
        ["Gadget Ultra", "5", "$75.00", "$375.00"],
        ["Connector Basic", "100", "$2.00", "$200.00"],
        ["Service Fee", "1", "$50.00", "$50.00"]
      ],
      "confidence": 0.97
    },
    {
      "page": 3,
      "index": 0,
      "rows": 3,
      "columns": 2,
      "headers": ["Tax Type", "Amount"],
      "data": [
        ["Sales Tax (8%)", "$90.00"],
        ["Service Tax (5%)", "$56.25"]
      ],
      "confidence": 0.92
    }
  ],
  "created_at": "2026-05-19T13:10:00Z"
}
```

## Example

```bash theme={null}
curl -X POST https://api.pdfbase.dev/v1/extract/tables \
  -H "Authorization: Bearer pk_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "source": { "pdf_id": "pdf_invoice" },
    "pages": "1-3",
    "format": "json"
  }'
```
