Skip to content
Beginner· 6 min read

Headless Browsers: Browsers Without a Window

A headless browser is a full web browser (typically Chromium) that runs without any graphical user interface — no window, no tabs, no address bar — controllable entirely through code.

Why This Matters

Every time an AI agent like Browser Use navigates a page, clicks a button, or extracts data, it is almost certainly using a headless browser. Headless browsers are the invisible engine behind nearly all modern web automation: testing frameworks, scraping pipelines, AI agents, and screenshot services.

Without headless browsers, you would need a physical monitor and a mouse-clicking robot to automate anything on the web. With them, you can spin up a hundred browser instances on a single server and control them all programmatically — no screens, no GPUs, no humans needed.

Prerequisites

Prerequisites

You should understand what a basic web browser does (fetch HTML, render the page, execute JavaScript, display content). A headless browser does all of that except the "display" part. Most headless browsers are built on Chromium, the open-source foundation of Google Chrome.

Core Idea

Imagine a regular browser — Chrome, Firefox, Edge. It has a window, tabs, an address bar, bookmarks, and all the UI you interact with. Now remove the window and everything visual. What's left? The engine that actually loads web pages, runs JavaScript, renders HTML, and manages cookies. That is a headless browser.

It is the same browser under the hood. Same rendering engine (Blink for Chrome, WebKit for Safari, Gecko for Firefox). Same JavaScript engine (V8 for Chrome). Same support for modern web standards. The only difference is the absence of a graphical interface.

graph TD
    subgraph "🖥️ Regular Browser"
        UI["Window, Tabs, Address Bar"]
        Engine["Rendering Engine"]
        UI --> Engine
    end
    subgraph "⚙️ Headless Browser"
        Engine2["Rendering Engine"]
        API["Programmatic API"]
        API --> Engine2
    end
    Engine2 --> Test["🧪 Automated Testing"]
    Engine2 --> Scrape["📊 Web Scraping"]
    Engine2 --> Agent["🤖 AI Agents"]
    Engine2 --> Shot["📸 Screenshots"]

    classDef ui fill:#2d2d2d,stroke:#4a4a4a,stroke-width:2px,color:#c9c9c9
    classDef engine fill:#1a3a2a,stroke:#34d399,stroke-width:2px,color:#34d399
    classDef api fill:#d4a853,stroke:#c49a3c,stroke-width:2px,color:#050505
    classDef task fill:#1c1c3a,stroke:#5b8cf6,stroke-width:2px,color:#87CEEB

    class UI ui
    class Engine,Engine2 engine
    class API api
    class Test,Scrape,Agent,Shot task

You control a headless browser through browser automation protocols — standardized APIs that let your code send commands. The most important are:

  • CDP (Chrome DevTools Protocol): The low-level protocol Chrome/Chromium speaks. Every Chrome-based automation tool (Puppeteer, Playwright, Browser Use) communicates through CDP under the hood.
  • WebDriver: The older W3C standard, primarily used by Selenium.
  • Playwright's own protocol: Built on CDP but adds cross-browser support (Chromium + Firefox + WebKit).

How It Actually Works

Two Modes of Headless in Chrome

Modern Chrome has two different headless modes, and the distinction matters:

ModeHow it worksBest for
--headless=new (new, default since Chrome 112+)Uses the real Chrome browser code. Shares the same rendering pipeline as headed mode. Renders pages accurately including WebGL, canvas, and modern CSS.AI agents, visual testing, page rendering — anything that needs realistic output.
--headless / chrome-headless-shell (old)A stripped-down, standalone binary that shares no code with the main Chrome browser. Faster startup but may render pages differently.Simple DOM extraction, high-volume scraping where visual fidelity doesn't matter.

The new headless mode is the correct choice for most modern use cases. The old mode is maintained for legacy compatibility but is effectively deprecated for new projects.

What a Headless Browser Can and Cannot Do

Can do:

  • Load HTML pages and execute JavaScript (including modern frameworks like React, Vue, Angular)
  • Render CSS, WebGL, Canvas, and SVG
  • Manage cookies, localStorage, sessionStorage
  • Handle network requests (with interception and modification)
  • Take screenshots and generate PDFs
  • Run in automated testing frameworks
  • Operate on servers with no display hardware

Cannot do:

  • Display anything on a screen (no GUI by definition)
  • Play audio or video through system speakers
  • Interact with browser extensions that depend on UI chrome (toolbar buttons, popups)

Performance Characteristics

Headless browsers are not necessarily faster than headed browsers. The new headless mode runs essentially the same code. The performance advantage comes from:

  • No GPU needed — runs on CPU-only servers
  • No rendering to screen — no VSync overhead
  • Programmatic control — you can skip animations, block images, intercept network requests
  • Scaling — dozens or hundreds of instances on a single machine

A typical headless Chrome instance uses 100–300 MB of RAM for a simple page and 500 MB–2 GB for complex SPAs.

Worked Example: Using a Headless Browser

The most popular library for controlling headless Chrome is Puppeteer (Node.js), but the same pattern applies to Playwright, Selenium, and Browser Use:

import puppeteer from 'puppeteer';

// Launch a headless browser (this starts Chromium with --headless=new)
const browser = await puppeteer.launch({ headless: true });
const page = await browser.newPage();

// Navigate — this loads the page, executes JS, renders CSS
await page.goto('https://example.com');

// Extract data — the browser has already rendered the page
const title = await page.title();
const heading = await page.$eval('h1', el => el.textContent);

// Take a screenshot — even though there's no window, the render is real
await page.screenshot({ path: 'example.png' });

console.log(`Title: ${title}, Heading: ${heading}`);
await browser.close();

Behind the scenes, Puppeteer communicates with the headless Chrome process through CDP over a WebSocket connection. Every command (goto, click, screenshot) is translated into CDP method calls.

Common Misconceptions

"Headless mode is faster than headed mode."

Not necessarily. Modern Chrome's --headless=new mode runs the same rendering engine. The difference is marginal for a single page. The real speed gains come from scaling (running many instances) and optimization (blocking images, disabling animations) — not from headless mode itself.

"Headless browsers can't be detected."

They absolutely can. Websites can check for many signals: the presence of --headless flags in the browser process, missing navigator.webdriver properties, or subtle differences in how rendering works. Anti-bot systems like Cloudflare and DataDome are sophisticated at detecting automated browsers.

"Headless mode means the page doesn't really render."

Not true in the new mode. The page is fully rendered in memory — JavaScript executes, CSS applies, WebGL textures are computed. Everything happens exactly as it would in a visible browser tab; you just can't see it. The screenshot capability proves this: the browser produces pixel-perfect images of pages it has "never displayed."

"All headless browsers are Chrome."

Chrome/Chromium dominates, but Firefox has --headless mode, WebKit has headless support (used by Safari), and there are niche players like Lightpanda (a browser built from scratch in Zig, optimized for AI agents and automation).

Key Takeaways

  • A headless browser is a full browser engine without a visible window — it loads pages, runs JavaScript, renders CSS, and supports all modern web features.
  • Modern Chrome's --headless=new mode shares the exact same code as the regular browser. The old standalone chrome-headless-shell is deprecated for new projects.
  • You control headless browsers through protocols like CDP (Chrome DevTools Protocol) or tools built on top of it: Puppeteer, Playwright, Selenium, and Browser Use.
  • Headless browsers can be detected and blocked by anti-bot systems — they are not inherently "stealth."
  • They are the invisible infrastructure behind AI agents, automated testing, web scraping, and screenshot/marketing services.

References

Related