What is a headless browser?
A headless browser is a real web browser that runs without a window. It loads pages, runs JavaScript, applies CSS and keeps cookies exactly like the browser on your desktop, but a program controls it instead of a person, through Playwright, Puppeteer, Selenium or the Chrome DevTools Protocol.
Headless browsers are the backbone of automated testing, web scraping, screenshots and PDFs, monitoring and AI agents, because they run on servers without a display and many can run side by side. Chrome's current headless mode is the full Chrome browser; its older, lighter implementation now ships separately as chrome-headless-shell.
Because so much automation runs headless, websites check for it: the HeadlessChrome user agent token, automation flags, default window sizes and software-rendered graphics are the classic tells. The answer isn't to avoid headless but to run a browser whose observable surface matches a normal one. See how headless browsers are detected and what an anti-detect browser is.
Updated
How a headless browser works
A headless browser is the same browser engine, started without its window: Chromium's Blink, Firefox's Gecko or Apple's WebKit. It still loads HTML, runs JavaScript, applies CSS, lays out and paints the page into an off-screen surface, and keeps cookies and storage. What changes is who is in control: instead of a person with a mouse and keyboard, a program sends it commands.
Those commands travel over an automation protocol. Chromium-based browsers speak the Chrome DevTools Protocol (CDP), which Puppeteer and Playwright use. Selenium uses the W3C WebDriver standard and, increasingly, WebDriver BiDi. Playwright drives Firefox and WebKit through protocols of its own.
A typical script launches the browser, opens a page, waits for an element to appear, reads it or clicks it, takes a screenshot if needed, and closes the browser. Everything a person could do in a tab, a script can do here, only faster and in parallel.
What headless browsers are used for
- Automated testing. End-to-end tests click through an app the way a user would, on every commit, in CI machines that have no screen. Visual regression tests compare screenshots between builds.
- Web scraping and data collection. Reading pages that only show their content after JavaScript runs, or after a click, a login or a scroll.
- Screenshots and PDFs. Rendering invoices, reports, social cards and archived copies of pages with the browser's own layout engine.
- Monitoring. Synthetic checks that load a page or walk through a checkout every few minutes and alert when it breaks or slows down.
- AI agents. Language models that browse, read and fill in forms do it through a browser, often a headless one on a server, controlled over CDP or an MCP server.
- Prerendering. Turning a JavaScript app into static HTML for clients that do not run scripts.
Headless vs headed browsers
| Headless | Headed (with a window) | |
|---|---|---|
| Window | None; the page renders off-screen | A visible window |
| Where it runs | Anywhere, including servers and containers without a display | Needs a display, or a virtual one such as Xvfb on a Linux server |
| Resources | Somewhat lower: no window or browser UI to draw | The full browser UI |
| Graphics | Uses the GPU if the machine has one; servers without one fall back to software rendering | The same rules |
| Window size | A small default (800×600 in Chrome) unless you set one | Whatever the window is |
| Debugging | Screenshots, logs, recorded traces | Watch it happen |
| How it looks to a site | Some traits differ from a person's browser unless configured | Closer to an ordinary session |
Headless Chrome: old and new headless
Until 2023, Chrome's headless mode was a separate, lighter implementation that shared the rendering engine but not the rest of the browser, and it behaved differently from normal Chrome in many small ways. Chrome 112 introduced a new headless mode, --headless=new, which is the real Chrome browser running without a window.
The old implementation became a separate binary, chrome-headless-shell, downloadable since Chrome 120. Chrome 132 removed it from the main Chrome binary in January 2025, so --headless now always means the new mode.
The automation libraries followed. Puppeteer launches the new headless mode by default since version 22 (headless: "shell" selects chrome-headless-shell instead). Playwright, since version 1.49, runs headless Chromium on chromium-headless-shell by default and switches to the new mode with channel: "chromium". More in what is headless Chrome.
Run a headless browser: code examples
Each example opens a page, prints its title and saves a screenshot (Puppeteer saves a PDF). All four run headless by default or with one option.
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch() # headless is the default
page = browser.new_page()
page.goto("https://example.com")
print(page.title())
page.screenshot(path="example.png", full_page=True)
browser.close()Headless browsers and the tools that drive them
- Chrome and Chromium (new headless). The full browser without a window, and what most automation targets, because it is what most visitors use. Microsoft Edge, Brave and other Chromium-based browsers share it.
- chrome-headless-shell. The old, lighter headless implementation, now its own binary: quick to start, but not identical to Chrome.
- Firefox. Runs headless with
-headless, driven by Playwright, Selenium or WebDriver BiDi. - WebKit. Safari's engine, headless through Playwright's WebKit builds.
- The drivers. Playwright (Node, Python, Java, .NET), Puppeteer (Node) and Selenium (most languages) launch these browsers and send the commands.
- History. PhantomJS, a WebKit-based headless browser, was the usual choice before Chrome had a headless mode; its development was suspended in 2018.
Headless browser scraping: when you need one
Use a headless browser when the data only exists after JavaScript runs (single-page apps), when you have to interact to reach it (clicking, logging in, scrolling an infinite list), or when you need what a person sees, such as a screenshot or a PDF.
Skip it when you can. Many sites load their data from a JSON API that an HTTP client can call directly, and server-rendered pages need no browser at all. Open your browser's developer tools, check the Network tab, and try a plain request first: it is faster, cheaper and simpler to run.
When you do use one:
- Wait for the element you need, not a fixed number of seconds.
- Block images, fonts and media you do not need, to save time and bandwidth.
- Reuse one browser and open new contexts or pages, rather than launching a browser per URL.
- Limit concurrency, add delays, and respect robots.txt and the site's terms.
A worked example with Selenium: how to scrape a website with Selenium. For a browser built for this job, see what a scraping browser is.
Why websites detect headless browsers
Many sites treat a headless browser as a sign of automation. The classic tells are a HeadlessChrome token in the user agent of Chrome's headless mode, navigator.webdriver set to true under automation, the small default window, and software-rendered graphics on servers without a GPU. Newer checks are about consistency: whether the GPU name matches what the canvas draws, and whether workers agree with the page. See how a headless browser is detected.
Clearcote is a Chromium build whose identity is set inside the engine, so a headless session reports the same coherent persona as a windowed one, with no automation switch. It does not promise that automation goes unnoticed; it removes the contradictions a headless browser usually has. See how detection works.
