# HTML Table to JSON Extractor - Rowspan and Colspan (`variable_mitts/html-table-span-extractor`) Actor

Convert supplied HTML tables to JSON grids. Expand supported rowspan and colspan cells and preserve cell origins with per-document diagnostics.

- **URL**: https://apify.com/variable_mitts/html-table-span-extractor.md
- **Developed by:** [Dhan sites](https://apify.com/variable_mitts) (community)
- **Categories:** Developer tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.48 / 1,000 input work unit inspecteds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## HTML Table to JSON Extractor - Rowspan and Colspan

Extract tables from supplied HTML into JSON grids. Expand supported rowspan and colspan values, retain cell origins and report malformed or oversized input per document.

### Start with this workflow

Convert supplied HTML tables into reviewable JSON grids.

**After the run:** Inspect grid coordinates, cell origins and per-document diagnostics. No URLs are fetched, scripts executed or browser layout rendered.

**What is billed:** Each inspected HTML document, not each extracted table, row or cell; invalid top-level input is free. Check the Pricing tab for the applicable subscription-tier rate. Result rows and billable input units can differ. A successful execution does not guarantee full coverage.

The example uses a small supplied fixture or the publisher-owned demonstration target. Replace it with input you are authorized to process; inspect coverage, diagnostics and limits before downstream use.

### Working example

```json
{
  "records": [
    {
      "html": "<table><tr><th rowspan=\"2\">Item</th><th colspan=\"2\">Price</th></tr><tr><td>USD</td><td>INR</td></tr><tr><td>A</td><td>12</td><td>1000</td></tr></table>"
    },
    {
      "html": "<p>No table here</p>"
    }
  ],
  "maxRecords": 10
}
```

### What the results mean

Processes only supplied HTML strings; no URL fetching, scripts or rendering. Extracts outer tables and excludes nested table text. Collapses cell whitespace; cell text is capped at10000characters. Expands spans1-100 and records original cell coordinates/header flags. rowspan=0 and overlapping spans are rejected. Unclosed tables are rejected; this is a bounded HTMLParser interpretation, not a full browser HTML5 repair engine. Max20 outer tables/document,5000 original cells,200 expanded rows,100 columns,10000 expanded cells/table,500000 expanded text characters/table and600000 serialized output characters/document. Run table-output budget2million characters; excess records get diagnostics. Input HTML cap100000characters/document.

### Outputs

The default dataset shows record_index, valid, table_count, tables, error. REPORT contains the full result and summary.processed/summary.truncated. Available file records: REPORT, BILLING. Result rows may differ from billed input units.

### Pricing

$0.6 per 1,000 inspected input work units ($0.0006 each) at the entry tier. Each inspected HTML document, not each extracted table, row or cell; invalid top-level input is free. Per-record rejections are inspected work. There is no run-start or automatic dataset-row event in the configured pricing. Inspect the Pricing tab for tier discounts, and REPORT/BILLING to reconcile inspected units.

### Limits and support

Default100 work units, maximum1000; at most10000 supplied records per array; serialized input2millioncharacters. The work cap applies before processing and is reduced by the run spending limit. Truncated output describes only the inspected prefix. No source data is changed, no websites fetched and no third-party API called. Run status alone is not validation: inspect REPORT and per-record errors. Use the Issues tab for support with a run ID and a small non-sensitive example. Never post private credentials.

### Who is this for?

Developers converting supplied HTML tables into structured grids. Paste HTML documents and inspect expanded spans and original cell coordinates.

### Frequently asked questions

#### Does this scrape URLs, render JavaScript or repair every HTML table?

No. It processes supplied HTML without fetching URLs or running a browser. It supports documented spans and rejects unsupported or oversized structures. It is not a full HTML5 browser repair engine.

#### How do I try it before using my full input?

Open the Input tab, review the prefilled example, and run a small batch with a spending limit. Inspect the dataset and report before increasing the batch. Examples can incur the documented inspection or analysis fee; an execution marked successful can still contain rejected records or incomplete coverage.

#### Can I use the Actor through an API or on a schedule?

Yes. Use Apify's [Actor API](https://docs.apify.com/api/v2/acts-run-sync-get-dataset-items-post) or [schedules](https://docs.apify.com/platform/schedules). Keep credentials private and use the documented input fields. The pricing and limits below apply to API runs too.

### Related tools for the next step

- [JSONL Validator - Invalid Lines and Clean JSONL Export](https://apify.com/variable_mitts/jsonl-validator-reject-export)
- [JSON Dataset Validator - Required Fields and Data Types](https://apify.com/variable_mitts/dataset-contract-field-checker)

# Actor input Schema

## `maxRecords` (type: `integer`):

One total cap on inspected input units, also bounded by the run spending limit. See the description for header/join/line counting.

## `records` (type: `array`):

Sample data is synthetic and never fetched as a URL. Replace with your own authorized input.

## Actor input object example

```json
{
  "maxRecords": 10,
  "records": [
    {
      "html": "<table><tr><th rowspan=\"2\">Item</th><th colspan=\"2\">Price</th></tr><tr><td>USD</td><td>INR</td></tr><tr><td>A</td><td>12</td><td>1000</td></tr></table>"
    },
    {
      "html": "<p>No table here</p>"
    }
  ]
}
```

# Actor output Schema

## `report` (type: `string`):

No description

## `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 = {
    "maxRecords": 10,
    "records": [
        {
            "html": "<table><tr><th rowspan=\"2\">Item</th><th colspan=\"2\">Price</th></tr><tr><td>USD</td><td>INR</td></tr><tr><td>A</td><td>12</td><td>1000</td></tr></table>"
        },
        {
            "html": "<p>No table here</p>"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("variable_mitts/html-table-span-extractor").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 = {
    "maxRecords": 10,
    "records": [
        { "html": "<table><tr><th rowspan=\"2\">Item</th><th colspan=\"2\">Price</th></tr><tr><td>USD</td><td>INR</td></tr><tr><td>A</td><td>12</td><td>1000</td></tr></table>" },
        { "html": "<p>No table here</p>" },
    ],
}

# Run the Actor and wait for it to finish
run = client.actor("variable_mitts/html-table-span-extractor").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 '{
  "maxRecords": 10,
  "records": [
    {
      "html": "<table><tr><th rowspan=\\"2\\">Item</th><th colspan=\\"2\\">Price</th></tr><tr><td>USD</td><td>INR</td></tr><tr><td>A</td><td>12</td><td>1000</td></tr></table>"
    },
    {
      "html": "<p>No table here</p>"
    }
  ]
}' |
apify call variable_mitts/html-table-span-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,variable_mitts/html-table-span-extractor"
        }
    }
}
```

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/ztOEf9MSUAamBRw0a/builds/3ZYDnhFzrEFDCrZLh/openapi.json
