# PDF Tables to JSON & CSV (`kitbench/pdf-tables-to-json`) Actor

Pull the tables it finds out of text-based PDFs as typed rows (numbers, money, percents parsed), ready to export as CSV or Excel. Scans are not supported. Pay per PDF where a table is found.

- **URL**: https://apify.com/kitbench/pdf-tables-to-json.md
- **Developed by:** [Micah](https://apify.com/kitbench) (community)
- **Categories:** Developer tools, Automation, AI
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $10.00 / 1,000 pdf with tables

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## PDF Tables to JSON & CSV

Give it links to PDFs. It returns every table it finds as clean, typed rows, ready to export as CSV, Excel or JSON.

- **CSV-ready by default.** Each table row is one dataset item and the table's columns are its fields, so an
  export is a flat table. `_sourceUrl`, `_table`, `_page` and `_row` say where each row came from. To get one item
  per table instead, set `outputMode` to `tables`.
- **Numbers come back as numbers.** `$1,234.50` becomes `1234.5`, `(45.00)` becomes `-45.0`, `12%` becomes `0.12`
  and `40` stays `40`. Identifiers stay text: `00123` and long digit strings are not turned into numbers.
- **A table that continues on the next page comes back as one table** when its header repeats there, which is how
  most generated reports print it.
- **Two tables on one page come back separately.** Each has its page, its position and its size.
- **A confidence score per table.** For ruled tables it is the share of cells on which two independent readings
  agree. For tables with only header rules it is how consistent the row widths are. Correctly read tables score
  0.9 or more. A misread one, such as values in the wrong columns, scores low.
- **Pay only for PDFs where a table is found.** PDFs with no table, refused links and failed downloads are free.
  Each still leaves a record (`_status`) saying why.

### Input

```json
{ "startUrls": [{ "url": "https://example.com/price-list.pdf" }], "outputMode": "rows", "maxPages": 100 }
```

Public URLs only (file upload is not in this version). Up to 500 PDFs per run, 1-300 pages each, 50 MB per file.

Three optional fields are under "Help improve this tool" and are described in [What this tool collects](#what-this-tool-collects):
`useCase` (what kind of documents these are), `shareAnonymousStats` (on by default, uncheck to turn it off) and
`shareFailingLinks` (off by default).

### Output (rows mode, one item per row)

```json
{ "_sourceUrl": "https://example.com/price-list.pdf", "_status": "ok", "_table": 0, "_page": 1, "_row": 0,
  "_confidence": 1.0, "SKU": "SK-1000", "Item": "Bolt 12 mm", "Qty": 40, "Unit price": 18.5, "Discount": 0.1 }
```

### Pricing

**$0.01 per PDF where at least one table is found**, charged after all its rows are saved. A PDF with no table, a
link that is refused or a download that fails costs nothing. Apify also charges a fixed $0.00005 each time the tool
starts, however many PDFs that run reads.

### What this tool collects

At the end of each run the tool sends the developer **one anonymous record**, unless you turn it off. It holds:

- the date of the run (UTC day only), and the version number of the record format;
- the tool's version, your `outputMode`, and a size band for `maxPages` (for example "51-100");
- your answer to "What are these PDFs?", if you gave one;
- how many PDFs ended each way: tables found, tables found with some pages skipped, no table, failed, link refused,
  stopped at the spending limit;
- the number of pages read and tables found, and how many tables scored below 0.5, from 0.5 to 0.9, and 0.9 or more;
- a band for how long the run took (for example "10-60s");
- which program made the PDFs (Word, Excel, LibreOffice, LaTeX, InDesign, Acrobat Distiller, Chrome, and so on, or
  "other" or "unknown"), counted per outcome. The tool reads the PDF's own producer field and keeps only the name of
  the group it falls in, never the text of the field.

**It never holds** your links, their domains, file names, anything written inside a PDF, your Apify account or user
id, or any other input value.

**Why:** to see which kinds of PDFs fail so they can be fixed, and which documents people bring so the tool is built
for them.

**Opt out:** uncheck "Share anonymous run statistics" (`shareAnonymousStats: false`). Nothing is sent then.

**Links are shared only if you ask.** If you check "Share links of PDFs that failed" (`shareFailingLinks: true`), the
links of the PDFs where no table was found, or that failed, are added to the record, at most 20 per run, with
everything after `?` or `#` removed (also when written as `%3F` or `%23`), any login in the link removed, and any
path parameters removed too (for example the `;jsessionid=...` some servers add, also when the semicolon is written
`%3B`). Links that were refused are never sent.

**Kept for 180 days**, then deleted.

Apify also has an account setting, "Share run data with developers". It is separate from this record and is yours to
switch on or off: when it is on, the developer can see your runs' inputs and outputs. The developer's own test runs
send nothing. To ask about any of this, open the Issues tab of this Actor.

### Limits

- **Born-digital PDFs only.** Scanned PDFs (images of pages) have no text to read, so they return `no-tables`.
  There is no OCR.
- **The table needs some rules:** a grid, or lines above and below the header. A table with no lines at all is
  not found. That is deliberate, so paragraphs of prose never come back as fake tables.
- **Only public links.** Links to private or internal network addresses are refused, at every redirect, and the
  download connects to the address that was checked. Plain `http` links work, because many public PDFs are still
  served that way.
- **A download that takes more than two minutes is given up** (a `failed` record, not charged), however slowly the
  server sends its response headers or the file, and so is a PDF over 50 MB. A server that sends the file compressed
  (a `Content-Encoding`) is refused.
- **If Apify restarts or moves a run,** the PDFs it had already finished are skipped, not read or charged again. The
  one PDF that was in progress is read again, and if the restart came while its rows were being saved or just before
  its charge, its rows can appear twice in the dataset; it is charged once, when it finishes. A charge can repeat
  only if the restart falls in the instant between a PDF's charge and the saving of its progress record, or if that
  record could not be saved (the run log says so).
- **Very large PDFs** are limited by `maxPages` rather than by a time limit.
- **Column names come from the table's heading.** A heading that spans several columns is split across them, and
  a heading printed outside the table's lines is not read: the columns are then named `column_1`, `column_2`, ...
  Footnote markers stay on labels (`Apparel1`). A table whose first data rows hold only codes other than the
  common ones (`(D)`, `(NA)`, `--`, `n/a`), such as `*` or `S`, can have those rows read into its heading.
- **Every table carries a confidence score.** For a table drawn as a grid it is how well two independent readings
  agree (the cell borders, and the whitespace between words). For a table with lines only above and below its
  heading there is one reading, and the score is the share of words that fall cleanly inside one column. Below
  0.9, check the table by eye.
- **A page that cannot be read is skipped, never silently:** the PDF's other tables still come back, and a
  `partial` record names the skipped pages.

### Accuracy

**Real PDFs.** 20 public releases from BLS, the Census Bureau, the Federal Reserve, the IRS and the EIA (October
2026\), first 50 pages each: 261 tables found, 28 of them (11%) scored below 0.9, most of those IRS worksheet forms
(numbered instruction lines with amount boxes) and a few tables whose cells run to paragraphs. The EIA weekly
petroleum report yields none, because its tables have no lines. Each PDF took under 10 seconds on a desktop PC.

Ten tables picked at random, their first rows compared cell by cell with the page: all ten were real tables, and
every value matched. Four earlier samples found faults that were fixed, among them row labels cut off where a
table has no outer rule, merged columns, numbers split by a stray space, and prose or instructions returned as
tables. Two independent code reviews then built about 35 more shapes that the fixes had broken or never handled
(headings of years or column numbers, suppressed values such as `(D)`, grouped rows with a blank first cell, fee
schedules with long labels, sparse grids, white headings on rounded or spot-colour bands, tables drawn as white
cells on a dark backing, two same-width tables on one page with prose, a caption or only space between them, a
contents page). Each one is now a test case, and real pages are pinned where the shape came from one.

**Generated PDFs.** 89 PDFs with exact answer keys, over 40 table shapes and 7 pages that hold no table (prose, a
contents page, a cover box, a worksheet): cell accuracy 100% on every shape, every heading kept as the heading,
and no table found where there is none.

# Actor input Schema

## `startUrls` (type: `array`):

Public links to the PDFs to read (http or https). Up to 500 per run.

## `outputMode` (type: `string`):

rows: one dataset item per table row, so CSV and Excel exports are flat tables. tables: one item per table, with typed rows, raw rows, page, position and confidence.

## `maxPages` (type: `integer`):

Pages read from each PDF (1 to 300).

## `useCase` (type: `string`):

Optional. Roughly what kind of documents these are. Sent to the developer only as part of the anonymous run statistics, so the developer can learn which documents people bring.

## `shareAnonymousStats` (type: `boolean`):

On by default. Sends the developer one anonymous record per run: counts of PDFs by outcome, pages and tables found, how sure the tool was, how long the run took, and which program made the PDFs (for example Word or LaTeX). It never includes your links, file names, PDF text or account. Uncheck to turn it off.

## `shareFailingLinks` (type: `boolean`):

Off by default. When checked, the links of PDFs where no table was found, or that failed, are sent to the developer so the tool can be fixed. Everything after ? or # (the query string and fragment), any login in the link and any ;parameters in the path (such as a session id) are removed first. Only check this for PDFs you are happy to share.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://www.irs.gov/pub/irs-pdf/p15.pdf"
    }
  ],
  "outputMode": "rows",
  "maxPages": 100,
  "shareAnonymousStats": true,
  "shareFailingLinks": false
}
```

# Actor output Schema

## `results` (type: `string`):

Dataset items: the table rows (or tables) with \_sourceUrl, \_page, \_table, \_row and \_confidence saying where each came from.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "startUrls": [
        {
            "url": "https://www.irs.gov/pub/irs-pdf/p15.pdf"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("kitbench/pdf-tables-to-json").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "startUrls": [{ "url": "https://www.irs.gov/pub/irs-pdf/p15.pdf" }] }

# Run the Actor and wait for it to finish
run = client.actor("kitbench/pdf-tables-to-json").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "startUrls": [
    {
      "url": "https://www.irs.gov/pub/irs-pdf/p15.pdf"
    }
  ]
}' |
apify call kitbench/pdf-tables-to-json --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,kitbench/pdf-tables-to-json"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/y22h85dzQDV3FJlld/builds/8ySYDzBlDetHrrYYS/openapi.json
