Stagehand is the SDK for browser agents.
Playwright was built for testing, Stagehand is built for agents. Use familiar APIs, self-healing actions, and network-level security across TypeScript, Python, and Go.
Wall-clock time
lower is better
Your agent's favorite browser tool
everything an agent needs to control a browser
Token efficiency as a priority
Our hybrid accessibility tree trimming gives your agents exactly what they need to understand the page and nothing more.
Familiar APIs
The Playwright-style methods you and your agents already know and love (goto, click, locator, screenshot).
Faster in production
Stagehand lives right next to the browser, so your agentβs actions feel instant, not remote.
a.cta β a[data-v2].cta β healed β
Self-healing primitives
Use Act, Observe, and Extract with natural language to automate pages. When sites change, we detect it and refresh how the actions happen on the page automatically.
Features Agents need
WebMCP, Clipboard Support, Self-healing actions, Batched commands, deep locators for nested iframes, and OTel support.
// how it's built
Stagehand runs as an extension next to the browser, closing the distance and reducing round-trip latency for all actions on the page.
// control a page with natural language
y combinator β top stories
// see the code
import { z } from "zod/v4";
import { localBrowser, Stagehand } from "@browserbasehq/stagehand";
const browser = await localBrowser.launch();
const sh = await Stagehand.create({ browser });
const page = await browser.context.activePage();
if (!page) throw new Error("Stagehand initialized without an active page");
await page.goto("https://news.ycombinator.com");
const result = await sh.extract(
"Extract the top 5 stories",
z.object({
stories: z.array(
z.object({
title: z.string(),
points: z.number(),
}),
),
}),
);
console.log(result.data.stories);
await sh.close();
await browser.close();| capability | stagehand | playwright |
|---|---|---|
| Designed for | agents | testing |
| Playwright-style API | yes | yes |
| Runtime lives in browser | yes | no |
| Shadow DOM and iframe support | yes | no |
| WebMCP support | yes | no |
| Domain allowlist/blocklist | yes | no |
| Built-in OTel tracing | yes | no |
2x
faster than playwright
80%
more token efficient
// why stagehand
Stagehand gives browser agents an interface built for how they actually work. It combines familiar Playwright-style APIs with self-healing actions, agent-optimized page context, and native support for complex DOM structures like out-of-process iframes and closed Shadow DOMs.
Agents use fewer tokens, recover when websites change, and complete tasks more reliably. With a complete browser driver across TypeScript, Python, and Go, Stagehand delivers the flexibility of AI without sacrificing the speed, control, determinism, reliability, and observability required in production.
Your agent should be able to use a browser like you do.
The SDK for browser agents