The browser tool, not the agent. You bring the brain.
The AI-native browser automation library — born from OpenClaw, built on Playwright, embeddable in any TS/Node agent loop. Snapshot + ref targeting: no CSS selectors, no XPath, no vision model — just numbered refs that map to interactive elements.
Most other tools in this space ship a complete AI agent: they take your task, own the LLM loop, decide what to click, and click it. Great — until you already have an agent. Then you've got two brains fighting over who's in charge.
browserclaw is just the eyes and hands. Call snapshot() and get an AI-readable text tree where every interactive element carries a numbered ref (e1, e2, …). The model reads text — the thing it's best at — and hands back a ref ID. browserclaw resolves that ref to one exact element through a Playwright locator and acts. Same page state → same ref → same result: deterministic targeting, no coordinate guessing, no LLM re-interpreting which element it meant. The reasoning stays in your code.
import { BrowserClaw } from 'browserclaw';
const browser = await BrowserClaw.launch({ url: 'https://demo.playwright.dev/todomvc' });
const page = await browser.currentPage(); // reuse the tab opened by launch; open() adds a tab
// Snapshot — the core feature
const { snapshot, refs } = await page.snapshot();
// snapshot: AI-readable text tree
// refs: { "e1": { role: "textbox", name: "What needs to be done?" }, "e2": { role: "link", name: "Playwright" } }
await page.type('e1', 'Buy groceries', { submit: true }); // Type by ref
await page.click('e2'); // Click by ref
await browser.stop();
Bring your own agent loop — or use ours
browserclaw never calls an LLM or decides anything; you do. The whole integration is snapshot in, ref out, act — here it is wired to a real model. Install @anthropic-ai/sdk and set ANTHROPIC_API_KEY and ANTHROPIC_MODEL to a model available to your account:
import { BrowserClaw } from 'browserclaw';
import Anthropic from '@anthropic-ai/sdk';
const llm = new Anthropic();
const model = process.env.ANTHROPIC_MODEL;
if (!model) throw new Error('Set ANTHROPIC_MODEL to a model available to your account');
const browser = await BrowserClaw.launch({ url: 'https://news.ycombinator.com' });
try {
const page = await browser.currentPage();
for (let step = 0; step < 20; step++) {
const { snapshot } = await page.snapshot();
const res = await llm.messages.create({
model,
max_tokens: 1024,
system: 'You drive a browser. Reply with JSON: { "action": "click" | "type" | "done", "ref"?, "text"? }.',
messages: [{ role: 'user', content: `Task: open the top story.\n\n${snapshot}` }],
});
const block = res.content[0];
const action = JSON.parse(block.type === 'text' ? block.text : '{}');
if (action.action === 'done') break;
if (action.action === 'type') await page.type(action.ref, action.text);
if (action.action === 'click') await page.click(action.ref);
}
} finally {
await browser.stop();
}
Swap Anthropic for any model — the snapshot is plain text in, a ref is plain text out. Layered, not bundled: the LLM, this library, and the agent are three independent pieces. Don't want to write the loop? Use browserclaw-agent — the open-source driver that adds obstacle recovery and learns a reusable skill per site. Bring your own brain, or use ours.
Why browserclaw?
browserclaw provides browser primitives you can call from an agent loop you already own:
- Deterministic — refs resolve through Playwright locators and bound DOM identities, one ref → one element. No coordinate guessing, no LLM re-interpreting targets between calls.
- Cheap & fast — a text snapshot is a fraction of the tokens of a screenshot, and there's no vision API round-trip in the targeting loop.
- Reliable — built on Playwright's auto-wait and locator engine, not homegrown DOM poking.
- Yours to compose — no framework opinions, no agent loop, no hosted platform. Drop it into whatever architecture you already have.
How browserclaw compares
Choose by the integration surface your application needs. Competitor details checked against their official documentation on October 10, 2026:
| Tool |
Integration surface |
Action selection |
| browserclaw |
JS/TS library; caller owns the loop |
Snapshot refs → Playwright locators; no model calls inside the library |
| browser-use |
Python agent library; Python/TypeScript Cloud SDK for hosted tasks and browser infrastructure |
Agent-driven tasks, or caller-controlled managed browsers |
| Stagehand |
SDK with browser methods and AI primitives; local or Browserbase browsers |
Direct locators plus natural-language act, observe, and extract; repeated AI calls can be cached |
| Playwright MCP |
MCP tools; supports programmatic server creation |
Snapshot refs or selectors through Playwright tools |
browserclaw exposes snapshots and actions directly in application code. It ships no agent loop or hosted browser service. The other tools also support composing browser operations into your application; their APIs, hosting options, and model involvement differ.
Case studies
Two proof-of-concept products are built on browserclaw, through browserclaw-agent:
- beelz.ai — bill pay. The agent is built to log in to a biller's own website, fill the payment form, and pay, with no per-provider integration.
- tovli.ai — charitable giving. The agent is built to complete the donation form on each nonprofit's own website.
Try It Live — Or On Your Machine
browserclaw.org is an open-source playground — type a prompt and watch an AI agent drive a real browser with browserclaw, live. No setup, no API keys, just a text box and a browser stream. It runs on this library in production, and browserclaw stays current by syncing with the upstream OpenClaw browser SDK.
Want to run it yourself? The source is at github.com/idan-rubin/browserclaw-agent — spin it up with Docker or Node.js. Supports Groq, Gemini, OpenAI, and Anthropic out of the box.
Install
npm install browserclaw
Requires a Chromium-based browser installed on the system (Chrome, Brave, Edge, or Chromium). browserclaw auto-detects your installed browser — no need to install Playwright browsers separately.
How It Works
┌─────────────┐ snapshot() ┌──────────────────────────────────────────┐
│ Web Page │ ──────────────► │ AI-readable text tree │
│ │ │ │
│ [buttons] │ │ - heading "todos" │
│ [links] │ │ - textbox "What needs to be done?" [e1] │
│ [inputs] │ │ - link "Playwright" [e2] │
└─────────────┘ └──────────────┬───────────────────────────┘
│
AI reads snapshot,
decides: type in e1
│
┌─────────────┐ type('e1',...) ┌──────────────▼──────────────────┐
│ Web Page │ ◄────────────── │ Ref "e1" resolves to a │
│ (updated) │ │ Playwright locator — one ref, │
│ │ │ one exact element │
└─────────────┘ └─────────────────────────────────┘
- Snapshot a page → get an AI-readable text tree with numbered refs (
e1, e2, e3...)
- AI reads the snapshot text and picks a ref to act on
- Actions target refs → browserclaw resolves each ref to a Playwright locator and executes the action
Note: Refs belong to the snapshot that created them. Navigation or DOM changes can invalidate them; stale refs may fail with a lookup error or timeout. Always re-snapshot before acting on a changed page.
API
Launch & Connect
// Launch a new Chrome instance (auto-detects Chrome/Brave/Edge/Chromium)
const browser = await BrowserClaw.launch({
url: 'https://demo.playwright.dev/todomvc', // navigate initial tab (no extra tabs)
headless: false, // default: false (visible window)
executablePath: '...', // optional: specific browser path
cdpPort: 9222, // default: 9222
noSandbox: false, // default: false (set true for Docker/CI)
ignoreHTTPSErrors: false, // default: false (set true for expired local dev certs)
userDataDir: '...', // optional: custom user data directory
profileName: 'browserclaw', // profile name in Chrome title bar
profileColor: '#FF4500', // profile accent color (hex)
chromeArgs: ['--start-maximized'], // additional Chrome flags
isolated: true, // fresh per-run profile, auto-cleaned on stop()
stealth: false, // default: false — inject JS patches (navigator.webdriver, plugins, WebGL vendor, …)
ciDefaults: false, // default: false — adds CI-deterministic Chrome flags (may fingerprint as automation)
recordVideo: { dir: './videos' }, // optional: record every page; videos flushed on page/context close
});
// Connect to an already-running Chrome instance
const browser = await BrowserClaw.connect('http://localhost:9222');
// Connect to an auth-protected CDP endpoint (e.g. an OpenClaw gateway)
const browser = await BrowserClaw.connect('http://host:9222', { authToken: '…', stealth: true });
// Auto-discovery: scans common CDP ports (9222-9226, 9229)
const browser = await BrowserClaw.connect();
connect() checks that Chrome is reachable, then the internal CDP connection retries 3 times with increasing timeouts (5 s, 7 s, 9 s) — safe for Docker/CI where Chrome starts slowly. If an attempt times out because a tab never answered during initialization, the retries stop and connect() throws UnresponsiveCdpTargetError naming that tab (err.targetIds): close the tab or restart the browser.
Always call stop() when finished. A handle created by launch() owns the Chrome process and terminates it on stop. A handle created by connect() releases its connection lease without terminating externally launched Chrome; the shared Playwright adapter closes when the last handle stops. Stopping one connected handle leaves other handles to the same endpoint usable. Stopping the launching handle still terminates its Chrome process, even if connected handles remain.
When headless Chromium is detected, browserclaw installs a guard that rejects modal WebAuthn passkey requests with NotAllowedError so clicks and keys remain usable. Conditional (autofill) requests retain their native behavior; use a headed browser for interactive passkey sign-in. A chrome-headless-shell executable can only be launched with headless: true.
On Linux, if TMPDIR exceeds 50 bytes, launch() gives Chrome /tmp for its temporary files so its socket path fits. The Chrome child also drops inherited jemalloc preload entries and MALLOC_CONF.
Anti-detection: launch() always passes Chrome the flag that disables the AutomationControlled Blink feature.
connect() attaches to an already-running Chrome, so it cannot add launch flags retroactively. To inject JavaScript
stealth patches for navigator.webdriver, plugins, WebGL vendor, and related browser signals, pass stealth: true to
launch() or connect().
Anti-bot / challenge detection
Detect — and optionally wait out — Cloudflare and CAPTCHA interstitials, so your agent can react instead of acting on a challenge page.
const challenge = await page.detectChallenge();
// null, or { kind, message }. kind ∈ 'cloudflare-js' | 'cloudflare-block' | 'cloudflare-turnstile'
// | 'hcaptcha' | 'recaptcha' | 'blocked' | 'rate-limited'
if (challenge?.kind === 'cloudflare-js') {
const { resolved } = await page.waitForChallenge({ timeoutMs: 20000 }); // pollMs default 500
if (!resolved) throw new Error('challenge did not clear');
}
waitForChallenge() polls until the page clears or the timeout elapses. JS challenges usually auto-resolve in a few seconds. The library's job is detection — CAPTCHAs (hCaptcha / reCAPTCHA / Turnstile) don't clear on their own. Pair detection with your own solver, a human in a visible window, or browserclaw-agent, whose built-in skills clear press-and-hold and Turnstile challenges via CDP.
Isolated profiles (per-run, per-process)
Pass isolated: true (or isolated: 'some-label') to launch in a dedicated per-run profile under $TMPDIR/browserclaw/isolated/:
- A run-scoped random suffix is always appended — including when you pass a label string. Two concurrent launches with the same label (
isolated: 'my-run') each get a unique directory and never collide on Chrome's SingletonLock. The label is for identification only; it does not produce a stable profile across runs.
stop() removes the isolated user-data directory on exit (best-effort; silent on failure). If the process crashes before stop(), leftover directories remain under $TMPDIR/browserclaw/isolated/ and can be deleted safely when no Chrome process is using them.
- When
isolated is set, profileName and userDataDir options are ignored.
- Any cookies, logins, extensions, or localStorage from prior runs are not available — by design.
For a stable, shared profile across runs (persistent login state, preserved history), omit isolated and use profileName / userDataDir instead. Browserclaw disables network prediction in its managed profiles. An explicit userDataDir retains its existing prediction preference, so Chrome may perform speculative networking outside page-request guards.
Stale-lock recovery (persistent profiles)