← home original tinybrowser.ericc.ch

tinybrowser

tinybrowser.ericc.ch
Profile A Profile B

tinybrowser is an experimental headless browser in a single ~19 MB Rust binary. Currently passing 70.4% of Web Platform Tests subtests ( 62.5% of files).

It speaks Chrome DevTools Protocol and W3C WebDriver (Classic + BiDi), so Playwright and Selenium *should* work. It also compiles to WebAssembly, which is how the demo above runs right inside your browser.

WEE WOO: still very experimental. Not all Web APIs are implemented yet (check the WPT page for what works), JS runs on QuickJS-ng with no JIT (JS heavy pages are slower than V8), there's no out-of-process iframe isolation yet, OS sandboxing isn't battle-tested, and rendering is headless one-shot PNGs only.

Install

AI agent setup prompt
Install tinybrowser and set it up for browser automation:

1. Install the binary:
   - npm (no global install): npx tinybrowser --help
   - macOS / Linux: curl -fsSL https://raw.githubusercontent.com/tinybrowser-dev/tinybrowser/main/install.sh | sh
   - Windows (PowerShell): irm https://raw.githubusercontent.com/tinybrowser-dev/tinybrowser/main/install.ps1 | iex
   - Ensure the install directory (~/.local/bin, %LOCALAPPDATA%\tinybrowser\bin, or $PREFIX/bin on Termux) is on PATH, then run `tinybrowser --help`, `tinybrowser daemon --help`, and `tinybrowser daemon start --help` to inspect all commands, endpoints, flags, and paths.
2. Start the browser daemon once per profile (stays open across tabs and commands; serves both CDP and W3C WebDriver on one loopback port):
   - `tinybrowser daemon start` (or `tinybrowser daemon start --port 4444`)
     Waits until the server is bound and a renderer is verified ready, then prints `{"profile","pid","host","port","url"}` on stdout.
   - Check or stop explicitly with `tinybrowser daemon status` and `tinybrowser daemon stop` (use `tinybrowser daemon serve` for foreground/supervisor mode).
3. Connect over CDP (`chromium.connectOverCDP("http://127.0.0.1:<port>")`, using `browser.contexts()[0].pages()[0]`) or W3C WebDriver (`POST http://127.0.0.1:<port>/session`).
4. For the WebAssembly build instead of the native binary: `npm install @tinybrowser/wasm`, then read https://github.com/tinybrowser-dev/tinybrowser/blob/main/packages/wasm/README.md.
5. Treat the source as ground truth. The documentation source pointers (https://tinybrowser.ericc.ch/#documentation) map every topic to its file: `crates/wasm/wit/browser.wit` for the WIT interface, `packages/wasm/README.md` for the loaders and storage state, and `tinybrowser --help` for flags and paths.
macOS and Linux
curl -fsSL https://raw.githubusercontent.com/tinybrowser-dev/tinybrowser/main/install.sh | sh
Windows (PowerShell)
irm https://raw.githubusercontent.com/tinybrowser-dev/tinybrowser/main/install.ps1 | iex
npm
npx tinybrowser --help
npx tinybrowser daemon start

# or install globally
npm install -g tinybrowser
WebAssembly SDK
npm install @tinybrowser/wasm
# or
bun add @tinybrowser/wasm

GitHub Releases

Agents love tinybrowser!

Documentation

Daemon

Start the daemon
tinybrowser daemon start
# {"profile":"default","pid":12345,"host":"127.0.0.1","port":41234,"url":"http://127.0.0.1:41234"}

tinybrowser daemon status
tinybrowser daemon stop

To connect Playwright over CDP, pass the printed URL to chromium.connectOverCDP.

Connect over CDP
import { chromium } from "playwright-core"

const browser = await chromium.connectOverCDP("http://127.0.0.1:41234")
const page = browser.contexts()[0].pages()[0]
await page.goto("https://example.com")
console.log(await page.title())

For WebDriver Classic, send POST /session to the same port. For BiDi, connect to ws://127.0.0.1:<port>/session.

WebAssembly

@tinybrowser/wasm ships as a WASI Preview 2 component. You pass the component, the module loader, the WASI shims, and the transport.

The Node entry needs Node 22 or later. Bun, browsers, and Workers use their own loaders. Keep core.wasm next to its two companion modules because the glue reads all three from one directory.

Node quickstart
import { createTinyBrowser } from "@tinybrowser/wasm"
import { instantiate } from "@tinybrowser/wasm/instantiate"
import {
  createNodeModuleLoader,
  createNodeTransport,
  createNodeWasi,
} from "@tinybrowser/wasm/node"

const browser = await createTinyBrowser({
  instantiate,
  module: createNodeModuleLoader(import.meta.resolve("@tinybrowser/wasm/core.wasm")),
  wasi: createNodeWasi(),
  transport: createNodeTransport(),
})

const tab = browser.createContext().openTab()
const result = await tab.goto("https://example.com/", { waitUntil: "networkidle" })

console.log(result.ok, result.reason, tab.title())
browser.dispose()

waitUntil modes

Mode Resolves when load the document's load event fired domcontentloaded DOMContentLoaded fired networkidle no in-flight fetches for 500 ms quiet no in-flight fetches, and load fired or 350 ms passed since content committed

goto, mount, back, forward, and reload default to load. restoreTabState and waitForIdle default to quiet.

API

Call What it does createTinyBrowser({ instantiate, module, transport, wasi }) Boots one engine. fonts, loadFonts, onWake, and onError are optional. browser.createContext({ userAgent, storageState }) A cookie and storage jar. Tabs belong to a context. context.openTab(url?, html?) Opens a tab. With no arguments it starts on a blank about:blank document; pass a URL and HTML string to mount a document instead. tab.goto(url, options) / tab.mount(url, html, options) Navigates. mount loads the HTML string as the document. tab.back(options) / tab.forward(options) / tab.reload(options) History traversal and refetch of the current entry, same result shape. An empty history is navigation-failed. tab.waitForIdle({ waitUntil }) Pumps timers and fetches without a new navigation. Defaults to quiet. tab.text() The rendered document's text. tab.eval(source) / tab.evalBounded(source, timeoutMs) Runs JS in the page and returns a string. The bounded form has its own wall clock. await tab.render(width, height) One-shot RGBA frame: { width, height, rgba }. This is the screenshot path; bring your own PNG encoder. context.exportStorageState() / context.importStorageState(state) Playwright-shaped cookies, origins, and optional IndexedDB. tab.exportTabState() / tab.restoreTabState(state) URL, history, and sessionStorage. restoreTabState reloads the saved entry. browser.dispose() Closes contexts, tabs, and the engine.

Source reference

Need / trigger File / URL Exact WIT interface: types, resources, host imports crates/wasm/wit/browser.wit WASM driver internals: waitUntil, pump budgets, wakeups, public types packages/wasm/src/driver.ts , packages/wasm/src/types.ts Browser loader, Workers loader, hop proxy, storage state JSON schemas packages/wasm/README.md Every CLI subcommand, flag, environment variable, and path src/cli.rs or tinybrowser --help npm CLI optional platform packages, target mapping, SHA-256 fallback, cache paths packages/cli/README.md , packages/cli/bin/tinybrowser.mjs Hosted Executor MCP app: Cloudflare Workers, SQLite persistence apps/executor/index.ts , apps/executor/README.md Live Web Platform Tests coverage and failing tests /wpt, latest.json