Stagehand icon

Stagehand

Control browser using Stagehand with AI automation

Extract

AI-generated

Summary

Extract structured data from a web page using AI-driven instructions and a defined schema to validate the extracted content.

Inputs

  • AI Provider (required) — Choose the AI provider to perform extraction, e.g., OpenAI, Anthropic, Google, Cerebras, or OpenRouter.
  • Instruction (required) — Natural language instruction directing the extraction task to be performed on the current page.
  • Schema Source (required) — Method to define the expected output schema: Field List, Example JSON, JSON Schema, or Manual Zod code.
  • Fields — When using Field List schema source, define the output fields, their types (string, number, boolean, array, object), and optionality.
  • Example JSON — When using Example JSON schema source, provide a sample JSON object representing the expected extraction output.
  • JSON Schema — When using JSON Schema source, provide a JSON Schema draft-07 compliant definition describing the output structure.
  • Manual Zod — When using Manual Zod source, provide Zod validation code describing the output schema.
  • Advanced Options — Optional settings including AI model selection, caching, verbosity level, DOM settle timeout, page load event to wait for, resource blocking, and others to customize extraction behavior.

Output shape

A single JSON object containing the extracted data structured according to the defined schema, plus metadata fields like operation name and optionally logs if enabled.

Extraction automatically manages browser session state; if no active session or page, it attempts to reconnect. The output JSON strictly validates against the chosen schema. Errors in extraction are returned as node errors with descriptive messages. Extraction uses AI models corresponding to the selected provider and model name, which can be configured via advanced options and credentials.

Examples

Example 1: Extract product information from a webpage listing using Field List schema source

Instruction specifies what to extract; Fields define product name (string), price (number), and availability (boolean).

Example 2: Extract structured metadata from a page using JSON Schema

Instruction guides the extraction; JSON Schema defines expected properties and types like title and description.

Discussion