HTML Tables to JSON API

Extract every table of a web page or HTML snippet to JSON or CSV, with merged cells (rowspan / colspan) expanded and multi-row headers combined.

GETPOSThttps://apibox.io.vn/v1/html-tables
Content & HTML▶ Try it online

The HTML tables API turns <table> elements into data. Give it a URL or raw html and it returns each table with its caption, id, number of rows and columns, column headers and the rows as objects keyed by header (or as plain arrays with format=rows). Merged cells are expanded into a regular grid, so a cell with rowspan="2" appears in both rows, and multi-row headers are combined (“Price / Buy”, “Price / Sell”).

Headers are detected from <thead> and rows of <th>, or from a first row of labels (header=first or none to force). Nested layout tables are skipped by default, min_rows drops tiny tables and index selects one table; with format=csv that table comes back as a UTF-8 CSV file (with BOM, so Excel opens Vietnamese text correctly).

Pages are fetched with the same protections as the other web APIs (no private addresses, 5 MB limit). Tables rendered by JavaScript after the page loads are not visible to the API.

Parameters

NameInTypeRequiredDefault
urlbody|querystringnoPage URL (or send html).
htmlbodystringnoRaw HTML.
indexbody|querynumbernoOnly this table (0-based).
formatbody|querystringnojsonjson, rows or csv (with index).
headerbody|querystringnoautoauto, first or none.
min_rowsbody|querynumberno1Skip tables with fewer data rows.

Example

curl -X POST "https://apibox.io.vn/v1/html-tables" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"html":"<table><thead><tr><th rowspan=\"2\">Tên</th><th colspan=\"2\">Giá</th></tr><tr><th>Mua</th><th>Bán</th></tr></thead><tr><td>USD</td><td>25,380</td><td>25,790</td></tr></table>"}'

Response

{
  "source": null,
  "table_count": 1,
  "returned": 1,
  "tables": [
    {
      "index": 0,
      "caption": null,
      "id": null,
      "rows": 1,
      "columns": 3,
      "headers": [
        "Tên",
        "Giá / Mua",
        "Giá / Bán"
      ],
      "data": [
        {
          "Tên": "USD",
          "Giá / Mua": "25,380",
          "Giá / Bán": "25,790"
        }
      ]
    }
  ]
}

Use cases

  • Scrape price lists, exchange rates and statistics tables
  • Import tables from Wikipedia into spreadsheets
  • Convert HTML reports to CSV for accounting
  • Monitor tables on supplier websites

FAQ

How are merged cells handled?

Their value is copied into every cell they span, so every row has the same number of columns.

Can I get Excel-friendly CSV?

Yes, format=csv&index=N returns UTF-8 with a BOM and CRLF line endings, which Excel opens with Vietnamese characters intact.

Why is a table missing?

It is probably built by JavaScript in the browser; the API reads the HTML returned by the server.

Related APIs

Start with 1,000 free requests every month. Get free API key →