Lightpanda: A Zig-Written Headless Browser That Cuts Memory 16x and Runs 9x Faster Than Chrome
"Not a Chromium fork. Not a WebKit patch."
This is the 252nd post in the "One Open Source Project a Day" series. Today's project is Lightpanda, a headless browser built specifically for AI agents and automation tasks.
Most web pages today are driven by JavaScript — SPAs, Ajax, React/Vue/Angular are everywhere — so a plain HTTP request often doesn't return the real content. That's why people spin up Headless Chrome to run crawlers and agents. But Chrome was designed for humans to view pages; it carries a whole set of headless features that aren't needed: rendering pipeline, GPU, various user-facing features. At scale, memory, startup speed, and deployment costs become problems.
Lightpanda's approach is to not modify Chrome at all, but to rewrite a browser from scratch in Zig: keeping the parts needed to "get the page content" — HTML parsing, DOM, V8 to execute JavaScript, network requests — and dropping graphical rendering. The cost is that web compatibility has to be chased down bit by bit; the benefit is an order-of-magnitude drop in resource usage.
What you will learn
- Why "no rendering" can cut memory and speed by an order of magnitude for a headless browser
- Lightpanda's component choices: Zig + V8 + libcurl + html5ever
- The four usage modes:
fetch,serve,mcp,agentand which scenarios they fit - PandaScript: turning an agent session into a deterministic script that costs zero tokens
- Current limitations: compatibility, platform support, and license considerations
Prerequisites
- Familiarity with headless browsers (Headless Chrome, Puppeteer, Playwright)
- Know what CDP (Chrome DevTools Protocol) is
- Optional: know MCP (Model Context Protocol)
Project Background
Project Overview
The official positioning is direct: a headless browser designed for AI agents and automation, written in Zig, a brand-new browser. Three explicit design choices:
- Not based on Chromium, Blink, or WebKit
- Written in Zig for explicit memory control
- No graphical rendering engine
Project Data
- ⭐ GitHub Stars: ~40,700
- 🍴 Forks: ~1,990
- 💻 Primary language: Zig
- 📅 Created: 2023-02-07
- 📄 License: AGPL-3.0 (review before commercial use or integrating into closed-source products)
- 💬 Community: Discord; contributing code requires signing a CLA
Main Features
Core Idea
Using Headless Chrome for agents / crawlers:
A full browser process → high memory, slow startup, heavy deployment
↑ When concurrency rises, cost mostly goes to "rendering capabilities we don't use"
Lightpanda's approach:
Keep only HTTP loading + HTML parsing + DOM + V8 to execute JS
↓ No rendering
↑ Same pages, memory and time drop significantly
Official Benchmarks
On AWS EC2 m5.large, requesting 933 real pages:
| Metric | Lightpanda | Headless Chrome | Difference |
|---|---|---|---|
| Peak memory (100 pages) | 123MB | 2GB | ~16x less |
| Execution time (100 pages) | 5 sec | 46 sec | ~9x faster |
These are the project's own published numbers, measuring tasks like "fetching page content". Scenarios needing screenshot-level rendering or complex interaction can't directly extrapolate.
Use Cases
- Large-scale page scraping: need to execute JS to get content, but don't want to pay for a Chrome instance per page
- Give AI agents browsing capability: connect via MCP Server or CDP
- Replace backend of existing Puppeteer/Playwright scripts: just change the connection endpoint, scripts mostly stay the same
- Freeze agent-discovered flows: replay with PandaScript, no token cost
Quick Start
Install
# macOS / Linux (Homebrew)
brew install lightpanda-io/browser/lightpanda
# Arch Linux
yay -S lightpanda-nightly-bin
# Nix
nix run github:lightpanda-io/browser -- --help
You can also download nightly binaries for Linux and macOS (x86_64 and aarch64), or use the official Docker image lightpanda/browser (amd64/arm64, CDP port 9222). There is no native Windows version; use WSL2.
Fetch a page
# Output as html / markdown / png / pdf / structured_data, etc.
lightpanda fetch --dump markdown https://example.com
Use --wait-until, --wait-ms, --wait-selector, --wait-script to control waiting timings, and --obey-robots to respect robots.txt. The structured_data format extracts JSON-LD, OpenGraph, and other structured data.
As a CDP server for Puppeteer
lightpanda serve --host 127.0.0.1 --port 9222
import puppeteer from 'puppeteer-core';
const browser = await puppeteer.connect({
browserWSEndpoint: 'ws://127.0.0.1:9222',
});
const page = await browser.newPage();
await page.goto('https://example.com');
console.log(await page.title());
await browser.disconnect();
Besides CDP, serve also supports Unix sockets and WebDriver BiDi (--protocol webdriver, or both protocols simultaneously).
Core Features
- Protocols: CDP over WebSocket, WebDriver BiDi
- Page capabilities: HTTP loading (libcurl), HTML parsing (html5ever), DOM, JavaScript (V8), XHR and Fetch, CORS, Cookies, custom headers, proxies, network interception, click and form input
- Other: robots.txt support, ad blocking
- MCP Server:
lightpanda mcp, JSON-RPC 2.0 over stdio, or add--portto serve/mcpover HTTP - Native Agent:
lightpanda agent, driven by natural language or slash commands; supports Anthropic, OpenAI, Gemini, Vertex AI, Mistral, Hugging Face, OpenRouter, any OpenAI-compatible endpoint, and local models like Ollama, llama.cpp
Detailed Project Analysis
Where the Saved Resources Come From
The biggest overhead in a browser is often rendering: style calculation, layout, paint, compositing, GPU processes. For an agent that only wants "the DOM after JS runs", these are wasted resources. Lightpanda keeps a lean pipeline:
URL → libcurl loading → html5ever parsing → DOM tree → V8 executing scripts
→ output HTML / Markdown / structured data / CDP events
No painting step means no memory structures for it. Combine that with Zig's explicit memory management, and you get the 16x memory gap in the official numbers. Note: the fetch command lists png and pdf outputs, but refer to official docs and actual pages for results; the primary positioning is content fetching, not pixel-level rendering.
Component Selection: Not Rebuilding Every Wheel
Lightpanda writes the browser skeleton and Web API layer itself, but delegates the heaviest parts to mature libraries:
| Part | Selection |
|---|---|
| Language | Zig |
| JavaScript engine | V8 |
| Networking | libcurl |
| HTML parsing | html5ever (Rust) |
This is a pragmatic choice: JS engines and the HTML5 parsing spec are extremely complex, so writing them from scratch is neither realistic nor necessary. The trade-off is a heavier build dependency stack — Zig 0.17.0, V8, libcurl, plus the Rust toolchain — so compiling yourself has a high bar.
Four Entry Points, Four Needs
| Command | Best For |
|---|---|
fetch |
One-off fetches, direct calls in scripts, CI |
serve |
Existing Puppeteer/Playwright code, swap backends |
mcp |
Give MCP clients like Claude browsing capability |
agent |
Interactive web exploration with natural language |
In MCP mode, sessions are isolated by default; clients sharing the same Mcp-Session-Id share one browsing context, with session_new, session_list, session_close to manage sessions. The run tool executes PandaScript with a default timeout of 60,000 ms.
PandaScript: Turning Agent Exploration into Deterministic Scripts
This is the most interesting design in my view. Having an LLM "look at the page and decide where to click" every time is slow and burns tokens. Lightpanda's agent session can be saved via /save into a JavaScript snippet with browser primitives, then replayed with lightpanda run script.js — no model, no token cost.
First time: Agent explores → finds a viable path → /save as script
After: lightpanda run script.js → deterministic replay, zero tokens
This builds "LLM as explorer, script as executor" directly into the tool. When a page redesign breaks the script, let the agent re-explore.
Compatibility: Let WPT Speak
The biggest risk for a new browser is "this page doesn't run". The project publishes Web Platform Tests results daily (perf.lightpanda.io/wpt), so coverage isn't a marketing claim; you can check it yourself. Before rolling out, test your target sites for real, don't rely only on benchmarks.
Boundaries to Watch
- License is AGPL-3.0: evaluate the network-use clause obligations before putting it in an externally provided service or closed-source product
- Platform: no native Windows; Linux binaries depend on glibc (x86_64 needs 2.35, arm64 needs 2.38); Alpine/musl won't work; no Android/Termux version
- Telemetry on by default: disable with environment variable
LIGHTPANDA_DISABLE_TELEMETRY=true - README doesn't list unsupported Web APIs item by item: whether your target site works requires your own testing
Project Link and Resources
- 🌟 GitHub: https://github.com/lightpanda-io/browser
- 📊 WPT results: perf.lightpanda.io/wpt
- 🐳 Docker image:
lightpanda/browser - 🧩 Agent Skill: lightpanda-io/agent-skill
- 💬 Community: Discord link in the README
Summary and Outlook
Core Takeaways
- Idea: design a browser for "getting content" rather than "showing humans", drop rendering
- Data: official test shows 100 pages at 123MB vs 2GB, 5 seconds vs 46 seconds
- Compatibility: CDP and WebDriver BiDi, Puppeteer/Playwright can connect directly
- AI-native: built-in MCP Server, multi-model Agent, and PandaScript for zero-token replay
- Boundaries: AGPL-3.0, platform limits, web compatibility needs self-verification
Who It's For
- Teams doing large-scale dynamic page scraping, held back by Chrome's resource usage
- Developers building browsing capabilities for AI agents
- People who want to freeze agent-discovered flows and reduce token costs
Learning Advice
Start by fetching a few pages you care about with fetch and compare the output with Chrome. Then use serve to run a small piece of existing Puppeteer script and check compatibility and resource usage. Only consider scaling up after confirming it works.
Visit PrimeSkills — a curated marketplace for AI agents and skills, all validated against real enterprise workflows. No gimmicks, only what actually works.
For more practical knowledge and interesting products, visit my personal homepage
Top 1 from juejin.cn, machine-translated. The original thread is authoritative.
Very detailed.