# Table to JSON + Diff (`sumizumi/table-to-json-diff`) Actor

Extract HTML tables from pages you own or may read into clean JSON records, and report added / removed / changed rows since the last run.

- **URL**: https://apify.com/sumizumi/table-to-json-diff.md
- **Developed by:** [Sumizumi Works](https://apify.com/sumizumi) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

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

## 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

## Table to JSON + Diff

Turn HTML tables on pages you own or are allowed to read into clean JSON records, and get **what changed since last time** (added / removed / changed rows) instead of re-reading the whole table.

Typical uses: your own price list or inventory page, a partner's public rate table you are permitted to monitor, a public timetable, a league table, a government open-data page, a status board. Feed the output to a spreadsheet, a Slack / Discord notification, or an LLM.

### What you get

One dataset item per table:

```json
{
  "url": "https://example.com/prices",
  "table_index": 0,
  "caption": "Price list",
  "headers": ["Item", "Price", "Stock"],
  "row_count": 42,
  "rows": [{"Item": "A-100", "Price": "1,200", "Stock": "in stock"}, ...],
  "diff": {
    "first_run": false,
    "previous_run_at": "2026-11-03T09:00:00+00:00",
    "counts": {"added": 1, "removed": 0, "changed": 3, "previous_rows": 41, "current_rows": 42},
    "added": [...], "removed": [...],
    "changed": [{"key": "A-100", "fields": {"Price": {"before": "1,100", "after": "1,200"}}, "after": {...}}]
  },
  "run_at": "2026-11-04T09:00:00+00:00"
}
```

- Header row becomes the keys (duplicate headers get `_2`, `_3`; empty headers become `col_n`).
- `colspan` is flattened; `thead` / `tbody` / `th`-less tables are handled.
- Give a **Key column** (e.g. `ID`) to get field-level changes. Without it, rows are matched by full content (added / removed only).
- Snapshots live in a named key-value store **in your account** (`snapshotStore`), so you can run this on a schedule and only act on `diff.counts`.

### Input

| Field | Meaning |
|---|---|
| `urls` | Pages to read (required) |
| `tableSelector` | CSS selector, default `table` |
| `headerRow` | First row is the header (default on) |
| `keyColumn` | Column that identifies a row, enables *changed* detection |
| `diffMode` | Compare with previous run (default on) |
| `includeRowsInDiff` | Off = counts only |
| `snapshotStore` | Name of the key-value store that keeps snapshots |
| `maxTablesPerPage` | Safety cap (default 20) |

### Pricing (pay per event)

You are charged only when a table is actually delivered: one `table-extracted` event per table, plus one `diff-computed` event per table that had a previous snapshot. Failed requests and pages with no matching table are free.

### Fair use

Plain HTTP fetch, one request per URL, no login, no anti-bot evasion, no JavaScript rendering. Use it on pages you own or have permission to read, and respect the site's terms and robots rules. For JavaScript-rendered tables, pre-render the page with a browser Actor and feed this Actor the HTML URL.

### Scheduling

Create a Task with your input, add a Schedule (e.g. every morning), and connect a webhook or an integration (Slack, Google Sheets, Make, Zapier) that fires when `diff.counts.added + changed + removed > 0`.

# Actor input Schema

## `urls` (type: `array`):

Pages that contain the HTML tables you want as JSON. Only use pages you own or are permitted to read.

## `tableSelector` (type: `string`):

CSS selector for the table(s). Default `table` takes every table on the page. Example: `#prices table`, `table.list`.

## `headerRow` (type: `boolean`):

Use the first row as column names. Turn off for tables without a header (columns become col_1, col_2, ...).

## `keyColumn` (type: `string`):

Optional column name that identifies a row (e.g. `ID`, `Product`). With a key, the diff reports *changed* rows field by field. Without it, rows are matched by their full content (only added / removed).

## `diffMode` (type: `boolean`):

Store a snapshot of each table and report added / removed / changed rows on the next run.

## `includeRowsInDiff` (type: `boolean`):

Turn off to get only the counts.

## `snapshotStore` (type: `string`):

Named key-value store that keeps the last snapshot per table (in your Apify account). Use different names to track separate projects.

## `maxTablesPerPage` (type: `integer`):

Safety cap.

## Actor input object example

```json
{
  "urls": [
    "https://en.wikipedia.org/wiki/List_of_largest_cities"
  ],
  "tableSelector": "table",
  "headerRow": true,
  "keyColumn": "City",
  "diffMode": true,
  "includeRowsInDiff": true,
  "snapshotStore": "table-to-json-diff-snapshots",
  "maxTablesPerPage": 20
}
```

# Actor output Schema

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

No description

# 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 = {
    "urls": [
        "https://en.wikipedia.org/wiki/List_of_largest_cities"
    ],
    "keyColumn": "City"
};

// Run the Actor and wait for it to finish
const run = await client.actor("sumizumi/table-to-json-diff").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 = {
    "urls": ["https://en.wikipedia.org/wiki/List_of_largest_cities"],
    "keyColumn": "City",
}

# Run the Actor and wait for it to finish
run = client.actor("sumizumi/table-to-json-diff").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 '{
  "urls": [
    "https://en.wikipedia.org/wiki/List_of_largest_cities"
  ],
  "keyColumn": "City"
}' |
apify call sumizumi/table-to-json-diff --silent --output-dataset

```

## MCP server setup

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

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/WqL1pbNTOTWD66AnT/builds/xRNMDpGOauGcguoc2/openapi.json
