Traditional headless browsers (such as Puppeteer or Playwright) orchestrate full multi-process Chromium instances that typically consume 350MB–800MB of RAM per instance with significant initialization overhead.
Headless Engine is designed as a purpose-built alternative: a fast, pure-Rust headless browser runtime that operates with a <30MB RSS footprint and sub-5ms initialization. It parses DOM trees directly, applies client fingerprint emulation to avoid automated bot triggers, and converts pages into clean, token-efficient Markdown optimized for LLM context windows.
Key Features
- 🪶 Low Memory Overhead: Sub-10MB idle RSS and ~15–35MB under active browsing, enabling high-density concurrency on resource-constrained servers.
- 🛡️ Fingerprint Emulation & Anti-Detection: Injects realistic client profiles (
navigator.webdriver = false, fullwindow.chromehierarchy, WebGL ANGLE vendor/renderer masking, Client Hints, and session persistence). - 🤖 Search & Knowledge Extraction: Built-in extraction for Google AI Mode (
udm=50), AI Overviews (SGE), Oxford Languages Knowledge Cards, YouTube video timestamps, and organic results. - 📝 LLM-Ready Markdown Distillation: Natively converts HTML DOM trees into clean Markdown by stripping navigation menus, ads, headers/footers, and boilerplate scripts (~85% token reduction).
- ⚡ Offline Ingestion & DOM Injection: Ingest raw HTML strings or local files into active tabs via
browser.set_content(html)orfile://URIs for offline parsing and deterministic testing. - 📱 Multi-Device Profiles: Switch between Windows Chrome, Linux Chrome, macOS Safari, iOS Safari, and Android Chrome.
- 🔌 Universal Multi-Language Support: First-class SDKs and bindings for Rust, Python, Node.js / TypeScript, Go, and Docker.
- 🗂️ Multi-Tab Isolation: Built-in arena-allocated tab manager (
BrowserEngine) for concurrent, isolated multi-tab automation. - 📡 Standard JSON-RPC 2.0 Interface: Connect over standard I/O for direct integration with AI agents and Model Context Protocol (MCP) servers.
Installation & Quick Start
1. 🦀 Rust Crate
use ;
async
2. 🐍 Python SDK (pip)
# Navigate with automated fingerprint emulation
=
# Extract token-efficient LLM Markdown
=
# Extract structured search entities (AI Overviews, PAA, Organic Results)
=
3. 🟢 Node.js / TypeScript SDK (npm)
import { HeadlessBrowser } from 'headless-engine';
const browser = new HeadlessBrowser();
const report = await browser.navigate('https://news.ycombinator.com');
const markdown = await browser.extractMarkdown();
console.log('Markdown:', markdown);
browser.close();
4. 🐹 Go Module
package main
import (
"fmt"
"github.com/yutuknown/headless-engine/sdk/go"
)
func main()
5. 🐳 Docker Container
6. ⚡ Standalone Binary Installers
- Linux & macOS:
| - Windows PowerShell:
iwr -useb https://raw.githubusercontent.com/yutuknown/headless-engine/master/scripts/install.ps1 | iex
Architectural Comparison
| Metric / Capability | Chromium (Playwright/Puppeteer) | Lightpanda (Zig) | Headless Engine (Rust) |
|---|---|---|---|
| Idle Memory (RSS) | ~120 MB | ~20 MB | ~9.4 MB |
| Active Memory (1 Tab) | ~350 MB – 600 MB | ~48 MB | ~15 MB – 32 MB |
| Active Memory (5 Tabs) | ~800 MB – 1.8 GB | ~180 MB | ~35.6 MB |
| Native Windows Support | ✅ Yes | ❌ WSL2 Required | ✅ Native Windows .exe + Linux + macOS |
| Startup Latency | ~800 ms – 1,500 ms | ~40 ms | < 5 ms |
| LLM Markdown Distillation | Requires third-party library | Basic HTML dump | Native AST Converter (~85% Token Reduction) |
| Structured SERP Parsing | Manual scraping required | None | Built-in (AI Overviews, PAA, Knowledge Cards) |
| Inter-Process Protocol | Chrome DevTools Protocol (CDP) | Partial CDP | Standard JSON-RPC 2.0 (Stdio / MCP) |
🤖 MCP Server & CLI Automation Example
Headless Engine provides a standard JSON-RPC 2.0 interface over Stdio:
package main
import (
"bufio"
"encoding/json"
"fmt"
"os/exec"
)
func main()
📚 JSON-RPC 2.0 API Reference
| Method | Parameters | Description |
|---|---|---|
tab.navigate |
{ "url": "...", "tab_id": "..." } |
Navigates to target URL with fingerprint emulation |
tab.setContent |
{ "html": "...", "url": "...", "tab_id": "..." } |
Injects raw HTML into the tab for offline parsing |
tab.extractMarkdown |
{ "selector": "...", "tab_id": "..." } |
Returns filtered, token-efficient LLM Markdown |
tab.extractResults |
{ "tab_id": "..." } |
Returns structured search entities (AI Overviews, PAA, results) |
tab.extractLinks |
{ "tab_id": "..." } |
Returns list of { text, href } pairs |
tab.extractForms |
{ "tab_id": "..." } |
Returns interactive form schemas and inputs |
tab.extractDom |
{ "selector": "...", "tab_id": "..." } |
Returns raw HTML of page or CSS selector |
tab.click |
{ "target": "selector_or_text", "tab_id": "..." } |
Simulates element click with auto-navigation |
tab.type |
{ "selector": "...", "text": "...", "tab_id": "..." } |
Simulates keyboard text input |
tab.evaluateJs |
{ "code": "...", "tab_id": "..." } |
Evaluates JavaScript expression in isolated runtime |
tab.setProfile |
{ "profile": "SafariMac", "tab_id": "..." } |
Updates active device fingerprint |
engine.createTab |
{ "profile": "ChromeWindows" } |
Spawns a new isolated tab, returns tab_id |
engine.closeTab |
{ "tab_id": "tab_1" } |
Closes and cleans up a tab instance |
engine.listTabs |
{} |
Lists all active tabs and their profiles |
shutdown |
{} |
Gracefully terminates the engine process |
📜 License
Licensed under either of:
- MIT License (LICENSE-MIT or opensource.org/licenses/MIT)
- Apache License, Version 2.0 (LICENSE-APACHE or apache.org/licenses/LICENSE-2.0)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project shall be dual-licensed as above, without any additional terms or conditions.