Glossary

Table structure recognition

Table structure recognition recovers the rows, columns, merged cells and headers of a table found in a document, so its contents can be read as data rather than a stream of numbers.

Table structure recognition (TSR) is the task of recovering the internal structure of a table in a document: which text belongs to which cell, how cells line up into rows and columns, which cells span several rows or columns, and which rows or columns are headers. It runs after a table has been located on the page and before its contents are turned into usable data. The output is a grid, usually expressed as HTML, JSON, Markdown or a dataframe, in which every value sits at a known row and column under known headers. Without table structure recognition, a financial statement or a specification sheet extracts as a flat run of numbers that no person or model can read reliably.

Where table structure recognition fits

Getting data out of a table is usually split into four steps, and the terms are often blurred.

Step

Question

Output

Table detection

Is there a table on this page, and where?

A bounding box around each table

Table structure recognition

How is this table organised?

Rows, columns, cells, spans, header rows

Cell content extraction

What does each cell say?

Text per cell, from the text layer or OCR

Functional analysis

What do the cells mean?

Headers linked to values, units, data types

Table detection is part of document layout analysis, which labels the table region alongside paragraphs and figures. Table structure recognition works inside that region. Cell content comes from the PDF’s text layer or from OCR on scans. The whole sequence is what most people mean by table extraction, and table structure recognition is its hardest step.

Why tables are hard

A table looks simple to a reader because the eye uses alignment, spacing, lines and context together. Software sees positioned text and, sometimes, drawn lines.

Borderless tables. Many tables have no ruling lines, only white space. Columns must be inferred from how text aligns, and a long value that spills across a column gap can merge two columns.

Spanning cells. A header such as “2026” may span four quarterly columns beneath it, and a row label may span several rows. Spans are essential to meaning and easy to lose.

Multi-level headers. Financial and scientific tables often have two or three header rows that combine: “Revenue” over “Europe” over “Q3”. Each value needs all of them to make sense.

Multi-page tables. Long tables continue across pages, sometimes repeating the header and sometimes not. Joining the parts, and not treating the repeated header as data, needs page-level context.

Irregular content. Cells can contain several lines of text, footnote markers, units, empty values, nested sub-tables or images. Totals rows, indented sub-items and section rows break the regular grid.

Scans and photos. Skew, blur and low resolution affect both the structure and the text. A slightly rotated scan can misalign every column.

How table structure recognition works

Rule-based methods. The earliest approaches use ruling lines and alignment. In a “lattice” approach, the lines drawn in the PDF define the grid directly; in a “stream” approach, gaps in white space and the alignment of text define it. Open-source tools such as Camelot and Tabula expose both modes. Rules are fast and precise on clean digital tables with borders and fail on borderless, spanning or irregular tables.

Learned models treat the table image as a scene and detect rows, columns, header regions and spanning cells as objects, then intersect rows and columns to form cells. The Table Transformer model, trained on the large PubTables-1M dataset of tables from scientific articles, is a well-known example. This approach handles borderless tables much better than rules and works on scans.Object detection of rows and columns.

Image-to-markup models. Another family reads the table image and generates its structure directly as HTML tokens, much as a captioning model generates text. Datasets such as PubTabNet, which pairs table images with HTML, made this approach practical. It naturally represents spans, because HTML has rowspan and colspan.

Graph-based methods. Some systems treat each text fragment as a node and predict which nodes share a row, share a column or belong to the same cell. This handles irregular layouts well and uses both position and content.

Vision-language models. A vision-language model can be asked to read a table image and return HTML, Markdown or JSON. On varied, messy tables it often does well with no task-specific training. The risks are the usual ones: occasional dropped rows, swapped values and invented numbers that look plausible. For tables that drive financial or legal decisions, outputs need validation, for example checking that columns sum to the stated totals. OCR vs. vision-language models covers the broader trade-off.

Measuring table structure recognition

Two metrics dominate research. TEDS (tree-edit-distance-based similarity) converts the predicted and reference tables to HTML trees and measures how many edits turn one into the other; a variant scores structure only, ignoring cell text. GriTS (grid table similarity) compares tables as two-dimensional grids and reports separate scores for topology, cell content and cell location. Older work used precision and recall on pairs of adjacent cells.

For a production system, the practical test is simpler: on a sample of your own tables, how often is every value under the right header? A table that scores 95 per cent on a similarity metric can still have one misplaced column, which makes every number in it wrong for downstream use. Checking row and column counts, header text and known totals catches most of these errors automatically.

Output formats

The format chosen for the result affects what survives.

HTML represents everything, including merged cells and multi-row headers, and is the usual research format. JSON with explicit cell coordinates and spans is best for programs that compute on the data, and pairs naturally with structured output. Markdown tables are compact and read well by language models, but they cannot express merged cells, so spans have to be flattened by repeating values. CSV or dataframes suit analysis but lose header hierarchy unless headers are combined into single column names. JSON vs. Markdown for LLMs discusses the trade-off for model input.

After the grid: cleaning table data

Recovering the grid is not the end. Values usually need data normalization before they are useful: “(1,204)” is a negative number in accounting notation, “1.204,50” is a European decimal, “n/a” and “-” mean empty, and units often sit in the header rather than the cell. Footnote markers attached to numbers (“4.2a”) have to be split off and linked to their notes. Totals rows and subtotal rows should be flagged so they are not summed twice.

Document type changes the priorities. Invoices and receipts have short, regular line-item tables where the main risk is a missed row, which is why invoice OCR and receipt OCR tools validate line items against the stated total. Forms mix tables with labelled fields, which overlaps with form extraction. Scientific and financial reports have the deepest headers and the most spans. A scanned PDF of any of these adds OCR error on top of structure error, so the two are best checked together.

Tables in RAG and agents

Tables are where many RAG systems quietly fail. Chunking by character count splits tables mid-row, and a chunk containing rows without their headers is almost meaningless: “4.2 | 3.9 | 18%” retrieves for nothing and answers nothing.

Teams that handle tables well do a few things. They keep each table, or each group of rows with its headers, as one chunk. For large tables, they repeat the header with every chunk or write each row as a sentence (“Revenue, Europe, Q3 2026: 4.2 million”), which helps both embeddings and keyword search. They keep the page number so answers can cite the source. And for tables that users query with calculations, they load the recovered data into a database and let the agent query it directly rather than reading numbers from text.

A worked example: an insurer’s agent is asked for the excess on a policy for a particular vehicle class. The answer sits in a schedule table with a two-row header and a spanning “Comprehensive” column. With structure recovered, the agent retrieves the row for that vehicle class with its headers attached and reads the right value. Without it, the agent retrieves a chunk of numbers and either declines or guesses. Use cases such as insurance claims processing and due diligence depend on this step, and structured data extraction builds on it.

Table structure recognition with Exabase

Exabase handles tables as part of document parsing in Exabase Extract. Submit a PDF, Word document or image and Extract returns text chunks with page numbers and, with ?format=markdown, a Markdown version of the document that language models read well. For recognised document types, Extract returns structured fields: invoices come back with vendor, invoice number, dates, lineItems and total, the most common table-shaped data most teams need. The retrieving results guide describes the output, and the invoice to JSON and PDF to Markdown tools show it for a single file.

Extract does not document a general table output with cell coordinates and spans for arbitrary tables. Teams whose product depends on exact grid structure, such as financial statement analysis, should test their own tables and, where needed, run a dedicated table model alongside, storing the result as Resources so Deep Search can retrieve it with page references. Exabase is the extraction and retrieval layer here; reconciliation, calculations and judgements on the data are the builder’s logic on top.

The file extraction solution and invoice processing show the setup in practice. For specialist tools, see the best PDF extraction APIs, Exabase vs. Reducto and Textract vs. Google Document AI, and the post on tables in PDFs.

Frequently asked questions

What is the difference between table detection and table structure recognition?

Table detection finds where tables are on a page. Table structure recognition works inside a detected table to recover its rows, columns, cells, spans and headers.

Why do borderless tables fail?

Without ruling lines, columns must be inferred from text alignment and white space. Long values, uneven spacing and spanning headers make that inference unreliable for rule-based tools.

How is table structure recognition evaluated?

Common metrics are TEDS, which compares HTML trees of predicted and reference tables, and GriTS, which compares grids for topology, content and location. Production teams also check row counts, headers and totals.

Can large language models read tables?

Vision-language models can read table images and return HTML, Markdown or JSON, often well. They can also drop rows or alter numbers, so important tables need validation against totals or the source.

What format is best for extracted tables?

HTML or JSON with spans keeps full structure. Markdown is compact and model-friendly but cannot represent merged cells. Choose based on whether a program or a model will consume the table.

Does Exabase do table structure recognition?

Exabase Extract parses documents into page-numbered chunks and Markdown, and returns structured line items for invoices. It does not document a general cell-level table output, so test your own tables if exact grid structure matters.

Related pages: Table extraction, Document layout analysis, Reading order detection, PDF parsing, Structured data extraction, Key-value extraction, File extraction solution, Best PDF extraction APIs, Invoice to JSON, LlamaParse alternatives

Cut your token spend and give your agent precise context.

Get started in minutes.

Cut your token spend and give your agent precise context.

Get started in minutes.