For the complete documentation index, see llms.txt. This page is also available as Markdown.

Parse HTML Form to Structured JSON

An example request that uses Gaffa to analyze a web form and extract all input fields, their labels, types, and properties into structured JSON.

The following example is a request we've pre-built to show you Gaffa's capabilities against our demo site. You can run this request right now in the Gaffa API Playground.

This example demonstrates how to extract structured information from HTML forms on web pages. Gaffa uses AI to identify form elements and their properties, making it perfect for form automation, testing, accessibility audits, or building form-filling assistants.

API Request

The request below uses the POST endpoint to open the demo form page, wait for the modal to appear, and then parse the visible form to extract all field information, including labels, input names, placeholders, and dropdown options.

{
  "url": "https://demo.gaffa.dev/simulate/form?loadTime=3&showModal=true&modalDelay=5&formType=address",
  "async": false,
  "max_cache_age": 0,
  "settings": {
    "record_request": false,
    "actions": [
      {
        "type": "wait",
        "selector": "form",
        "timeout": 10000
      },
      {
        "type": "parse_json",
        "data_schema": {
          "name": "FormFields",
          "description": "Extract all form input fields",
          "fields": [
            {
              "type": "string",
              "name": "form_title",
              "description": "Form title"
            },
            {
              "type": "array",
              "name": "fields",
              "description": "List of all input fields",
              "fields": [
                {
                  "type": "string",
                  "name": "label",
                  "description": "Field label"
                },
                {
                  "type": "string",
                  "name": "field_name",
                  "description": "Field name attribute"
                },
                {
                  "type": "string",
                  "name": "field_type",
                  "description": "Input type"
                },
                {
                  "type": "boolean",
                  "name": "required",
                  "description": "Is required?"
                },
                {
                  "type": "string",
                  "name": "placeholder",
                  "description": "Placeholder text"
                }
              ]
            }
          ]
        },
        "instruction": "Extract all form fields with their properties",
        "model": "gpt-4o-mini",
        "output_type": "inline"
      }
    ]
  }
}

Actions

WaitParse JSON

Response

The parsed form data is returned as a structured JSON object:

Last updated