Table extraction

Also known as: table structure recognition

On this page 7

Table extraction is the task of locating tables in documents and converting them into structured data in which every cell is assigned to the correct row, column and header. In Document AI, it covers both finding the table on the page and table structure recognition, the step that reconstructs the grid, spanning cells and header hierarchy so the content can be loaded into a spreadsheet, database or downstream model.

Table extraction is harder than plain text recognition because meaning depends on position. A number is useless unless the system knows which row label and column header it belongs to, so a single misaligned cell can corrupt an entire financial statement or laboratory report.

The table extraction pipeline

A classical table extraction system runs as a sequence of specialized stages, each of which can fail independently. Modern end-to-end models merge some stages, but the logical steps remain the same.

StageTaskTypical output
Table detectionFind table regions on the pageBounding boxes
Structure recognitionIdentify rows, columns and spanning cellsGrid of cell coordinates
Cell content recognitionRead text inside each cellText per cell, via OCR or PDF layer
Header and semantic analysisClassify headers, units and hierarchiesLabeled header tree
SerializationExport the resultCSV, HTML, JSON or Markdown
Stages of a typical table extraction pipeline

For born-digital PDFs, cell text can often be read directly from the text layer, which removes OCR errors. For scanned documents and photos, OCR accuracy, image quality, document deskewing and binarization strongly influence the final result.

Approaches and model families

Table extraction methods have evolved from rule-based heuristics to deep learning detectors and, more recently, to vision-language models that generate the whole table as text. Each family suits different document types.

ApproachHow it worksBest suited toMain weakness
Rule-based parsingUses ruling lines, whitespace and text alignmentClean, consistent digital PDFsBreaks on borderless or irregular tables
Object detection modelsDetect rows, columns and cells as boxesMixed layouts at scaleNeeds post-processing to build the grid
Image-to-sequence modelsGenerate HTML or Markdown from the imageComplex spanning structuresCan hallucinate or drop cells
LLM-based document extractionPrompts a multimodal model for structured outputVaried, low-volume documentsCost, latency and unverifiable errors
Main approaches to table extraction

In production, hybrid pipelines are common. A detector proposes table regions, a structure model builds the grid, and a language model handles semantic tasks such as mapping headers to a target schema. Open-source toolkits such as Docling combine these steps, while OCR-free models in the Donut and Pix2Struct tradition read the image directly.

Why some tables are difficult

The difficulty of table extraction depends far more on table layout than on document length. Simple grids with ruling lines are largely solved, while several layout features still cause frequent errors.

  • Borderless tables, where columns are implied only by whitespace and alignment.
  • Spanning cells that cover several rows or columns, common in multi-level headers.
  • Tables split across pages, which must be merged while repeated headers are removed.
  • Nested or hierarchical row labels, where indentation signals subtotals or categories.
  • Dense numeric tables in which a shifted decimal or a lost minus sign changes the meaning.

A frequent misconception is that high OCR accuracy guarantees good tables. Text can be recognized perfectly yet placed in the wrong cell, so structure errors and character errors must be measured separately.

Table extraction also differs from form extraction and key information extraction. Forms pair isolated labels with values, while tables encode two-dimensional relationships in which every value depends on both its row and its column. Line item extraction from invoices sits between the two, because it reads a table but maps each row to a fixed business schema with fields such as description, quantity, unit price and amount.

Measuring table extraction quality

Table extraction quality is measured with structure-aware metrics rather than plain text accuracy, because the goal is a correct grid. Different metrics answer different questions, and reporting more than one gives a fairer picture.

MetricWhat it measuresTypical use
Detection IoU and F1Overlap of predicted and true table regionsTable detection benchmarks
Adjacency relation F1Correct neighbor relations between cellsStructure recognition without text
TEDS scoreTree edit distance between predicted and true HTMLStructure plus content similarity
Cell-level accuracyShare of cells with correct position and textBusiness acceptance testing
Common evaluation metrics for table extraction

Benchmark scores often overstate real-world performance, because public datasets are dominated by scientific papers and clean financial filings. Organizations should evaluate on a sample of their own documents before committing to a tool.

Choosing a table extraction approach

The right approach depends on document source, volume, variability and the cost of errors. A decision made on these factors usually saves more effort than switching between models.

SituationRecommended approachReason
Born-digital PDFs, stable templatesRule-based parsing of the text layerExact text, low cost
Scanned documents, high volumeDetector plus structure model plus OCRScalable and predictable
Highly varied layouts, low volumeMultimodal LLM with schema validationFlexible without retraining
Financial or regulatory dataAny model plus checksums and human reviewErrors carry legal or monetary cost
Decision guide for table extraction projects

Whatever the method, automatic validation should accompany extraction. Row and column totals, expected data types and an extraction confidence score for each cell allow uncertain results to be routed to human review instead of passing silently into reports.

Stripped to the essentials

Table extraction teaches a computer to copy a table from a document into a spreadsheet. Reading the words is not enough. The computer must also know which box each word belongs to.

Think of moving a full egg carton without mixing up the eggs. Each egg must land in the same slot. If one number slips into the wrong column, the total becomes wrong. Good systems therefore check their own work and ask a person when they are unsure.

Where it is applied

A mid-sized accounting firm receives about 3,000 scanned bank statements and supplier invoices each month from small business clients. Staff previously retyped transaction tables into spreadsheets, which took roughly six minutes per page and produced frequent transposition errors.

The firm deploys a table extraction pipeline that detects transaction tables, rebuilds rows that continue across pages and reads amounts with OCR. Every extracted statement is validated by checking that the opening balance plus transactions equals the closing balance. Pages that fail this check, about 8 percent, go to a reviewer.

Processing time falls to under one minute per page on average, and because the balance check catches misread amounts, the error rate in the client ledgers drops below the level previously achieved by manual entry.