> For the complete documentation index, see [llms.txt](https://gaffa.dev/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gaffa.dev/docs/features/browser-requests/api-playground-examples/parse-an-html-table-to-json.md).

# Parse an HTML Table to JSON

*The following example is a prebuilt request that demonstrates Gaffa's capabilities on our* [*demo site*](https://demo.gaffa.dev/)*. **You can run this request right here in the*** [***Gaffa API Playground***](https://gaffa.dev/dashboard/playground?templateId=parse_table)***.***

This example demonstrates how to extract tabular data from any webpage without writing a scraper. Gaffa renders the page using a real browser, waits for the table to load, and returns the rows as a clean JSON array, making it perfect for building data pipelines, monitoring dashboards, or feeding structured data into LLM workflows.

## API Request

The request below uses the [POST endpoint](https://gaffa.dev/docs/api-reference/post-v1-browser-requests) to load a demo table page, waits for the table element to appear, and parses each row into a structured JSON array, using the table's header row as property names.

```json
{
  "url": "https://demo.gaffa.dev/simulate/table?loadTime=1&rowCount=3",
  "proxy_location": null,
  "async": false,
  "max_cache_age": 0,
  "settings": {
    "record_request": false,
    "actions": [
      {
        "type": "wait",
        "selector": "table",
        "timeout": 5000
      },
      {
        "type": "parse_table",
        "selector": "table"
      }
    ]
  }
}
```

## Actions

{% content-ref url="/pages/Py3syTPEzIuvQYXyaDso" %}
[Wait](/docs/features/browser-requests/actions/wait.md)
{% endcontent-ref %}

{% content-ref url="/pages/k6OW4oynrx9l5KvPURSV" %}
[Parse Table](/docs/features/browser-requests/actions/parse-table.md)
{% endcontent-ref %}

## Response

The `parse_table` action returns an `output` URL pointing to the extracted JSON:

```json
{
  "data": {
    "id": "brq_abc123ExampleRequestId",
    "url": "https://demo.gaffa.dev/simulate/table?loadTime=1&rowCount=10",
    "state": "completed",
    "credit_usage": 1,
    "http_status_code": 200,
    "from_cache": false,
    "started_at": "2025-06-09T12:00:00.000Z",
    "completed_at": "2025-06-09T12:00:04.321Z",
    "running_time": "00:00:04.3210000",
    "page_load_time": "00:00:01.1230000",
    "actions": [
      {
        "id": "act_wait001",
        "type": "wait",
        "query": "wait?selector=table&timeout=5000&continue_on_fail=false",
        "timestamp": "2025-06-09T12:00:01.500Z"
      },
      {
        "id": "act_parse001",
        "type": "parse_table",
        "query": "parse_table?selector=table",
        "timestamp": "2025-06-09T12:00:01.600Z",
        "output": "https://storage.gaffa.dev/brq/results/brq_abc123ExampleRequestId/act_parse001_table.json"
      }
    ]
  }
}
```

Fetching that URL gives you the table rows as a ready-to-use array:

```json
[
  {
    "id": "1",
    "name": "Item 1",
    "quantity": "30",
    "price": "$56.05"
  },
  {
    "id": "2",
    "name": "Item 2",
    "quantity": "68",
    "price": "$76.89"
  },
  {
    "id": "3",
    "name": "Item 3",
    "quantity": "67",
    "price": "$20.44"
  }
]
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://gaffa.dev/docs/features/browser-requests/api-playground-examples/parse-an-html-table-to-json.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
