lexmount/moli

Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust

Moli – A Headless Browser Built for AI Agents

What it is – Moli is an open‑source, production‑ready headless browser written in Rust. It provides a full web‑runtime (HTML, CSS, JavaScript, networking, storage, etc.) but is designed to keep the resource footprint tiny by rendering only when a visual output is explicitly requested. The binary can be driven via a simple CLI, the Chrome DevTools Protocol (CDP), or the standard WebDriver Classic / WebDriver BiDi interfaces, so existing automation tools (Playwright, Selenium, Puppeteer, etc.) can talk to it without extra adapters.


Why it matters for AI / LLM agents

  • Structure‑first workflow – Most agent tasks need the DOM, CSS cascade, or network data, not a continuously painted page. Moli reads the browser state directly, skipping layout and paint unless you ask for them.
  • Fast & lightweight – The default mode never does a real layout, keeping median memory around 70 MiB and start‑up latency under 35 ms, far lower than Chrome headless (≈ 770 MiB, > 150 ms).
  • On‑demand visuals – When a screenshot, PDF, or geometry query is needed, Moli builds a single layout tree, renders the frame, then discards the paint state. No persistent compositor or GPU work.
  • Unified protocol endpoint – One binary serves CDP, WebDriver Classic, and WebDriver BiDi, so you can pick the automation library you already use.

Core features (as described in the README)

Feature What it does
Complete web runtime HTML5 parsing, native DOM, V8 JavaScript, CSS cascade, fetch/XHR/WebSocket, cookies, WebCrypto, IndexedDB, OPFS, iframes, workers, etc.
Extraction‑optimized outputs moli fetch can dump HTML, Markdown, JSON, a semantic‑tree text format, or raw screenshots/PDFs.
CLI, CDP, WebDriver Classic & BiDi Same kernel behind all three; Playwright can connect via chromium.connectOverCDP.
On‑demand layout & paint --layout enables real geometry, hit‑testing, coordinate input, screenshots, and screencast frames; otherwise only a deterministic mock layout is kept.
Fine‑grained resource control Flags to enable optional families (--image, --font, --audio, …) and to point to custom profile, cache, or cookie files.
Cross‑platform Pre‑built binaries for Linux, macOS, and Windows.
Open‑source licensing Dual‑licensed under Apache‑2.0 or MIT.

Typical use cases for AI agents

  1. Web‑search & crawling – Fetch a page, wait for JavaScript to settle, and return a clean Markdown or JSON representation for downstream LLM reasoning.
  2. Data extraction – Query the DOM, run a small script (--eval) to click a button or expand a section, then export the resulting structure without ever rendering a picture.
  3. Interactive automation – Use the layout tree to compute element boxes, perform coordinate‑based clicks, or generate a single screenshot when visual confirmation is needed.
  4. Evaluation environments – Run reinforcement‑learning or tool‑use loops where many thousands of page loads are required; the low memory/CPU cost keeps the experiment affordable.
  5. Tool‑integration – Connect Playwright, Selenium, or any CDP client to the moli serve endpoint and treat it like a normal browser, but with a much smaller footprint.

Quick start (from the README)

# Linux / macOS – one‑liner installer
curl --proto '=https' --tlsv1.2 -fsSL \
  https://github.com/lexmount/moli/releases/latest/download/moli-installer.sh | sh

# Windows – PowerShell installer
powershell -ExecutionPolicy ByPass -c "irm https://github.com/lexmount/moli/releases/latest/download/moli-installer.ps1 | iex"

Fetching a page as Markdown

moli fetch --dump markdown --wait-until done https://example.com

Getting a semantic tree (model‑friendly)

moli fetch --dump semantic_tree_text --wait-selector body https://example.com

Screenshot on demand

moli fetch --layout --dump screenshot https://example.com > page.png

Running an automation server

moli serve            # DOM‑first only
moli serve --layout   # enable geometry & screenshots

How it works under the hood (high‑level)

  • Rust kernel – The browser is a native Rust program, not a Chromium wrapper.
  • Networking – libcurl handles HTTP(S) and multi‑request concurrency.
  • HTML parsing – html5ever builds the DOM tree.
  • JS engine – rusty_v8 embeds V8 for full JavaScript support.
  • CSS – Servo/Stylo provides selector matching and cascade computation.
  • Layout & text – Taffy (box layout) + Parley (text shaping) generate geometry only when --layout is requested.
  • Software rendering – AnyRender/Vello (CPU) plus usvg and the Rust image ecosystem produce PNG/PDF frames.
  • State model – The DOM + computed style are the single source of truth. When a visual operation is needed, a temporary working layout tree is built, frozen into a compact FrozenLayoutTree, used for the operation, then discarded. No persistent compositor or GPU pipeline exists.

Benchmarks (as reported)

Benchmark Moli Chrome Headless
Public‑web crawl (192 URLs) 53.6 % useful pages, median 1.43 s, 73 MiB RSS 52.6 % useful, 1.43 s, 773 MiB RSS
Sample agent workload CDP ready 34.85 ms, peak 102 MiB PSS CDP ready 169.37 ms, peak 349 MiB PSS
Lexbench‑Headless‑Browser (1,308 tasks) 81.9 % success, median CPU 100.6 ms, median memory 92 MiB 99.8 % success, median CPU 687 ms, median memory 697 MiB
WPT test suite 1.612 M tests passed (full run) –

These numbers illustrate that Moli achieves ≈ 15 % of Chrome’s CPU time and ≈ 13 % of its peak memory while still handling the majority of real‑world pages.


Project status & ecosystem

  • Production‑ready – The README states the browser is ready for production workloads and is under active development.
  • Relation to Lexmount – Moli is the open‑source core; Lexmount also offers a managed cloud service (Lexmount Browser) that builds on top of it, but the binary works fully standalone.
  • Community – Discord community link, Trendshift badges, and a star‑history graph indicate an engaged user base.
  • License – Dual‑licensed Apache‑2.0 / MIT, with third‑party components listed separately.

TL;DR for a non‑expert

Moli is a fast, low‑memory headless browser you can control from code or the command line. It gives AI agents the full power of a modern web page (JavaScript, CSS, networking) but skips the heavy visual rendering unless you explicitly ask for a screenshot or geometry. This makes it ideal for large‑scale web crawling, data extraction, or any AI workflow that needs to “read” the web without the overhead of a full Chrome instance.

Written about in

Related

  • Project
  • Project
  • Project
  • Project
  • Project