A headless browser is a web browser that runs without a graphical user interface and is controlled by code, yet still loads pages, executes JavaScript, and renders content like a normal browser. Chrome and Firefox both support headless mode natively, and libraries such as Puppeteer, Playwright, and Selenium drive it for testing, automation, and web scraping.
Chrome's headless and regular modes now share the same code. Since Chrome 132, the older, separate headless implementation is only available as a standalone binary called chrome-headless-shell.
How a Headless Browser Is Controlled
- Start the browser headless: Chrome runs headless with the
--headlessflag, and Puppeteer launches Chrome or Firefox headless by default. - Connect a script: Puppeteer controls the browser over the Chrome DevTools Protocol or WebDriver BiDi. Selenium uses the W3C WebDriver standard.
- Send commands: the script tells the browser which pages to open and what to do on them, such as clicking, filling forms, and waiting for dynamic content.
- Read the result: the script reads back the rendered page, a screenshot, or extracted data.
Headless Browser vs. HTTP Client
| Headless browser | HTTP client (e.g., curl, Requests) | |
|---|---|---|
| Runs JavaScript | Yes | No |
| What it downloads | The page plus its images, scripts, styles, and fonts | Only the URLs you request |
| Client fingerprint | The browser's own | The library's own |
| Resource use | A full browser process | A single request |
Scrapy's documentation calls reproducing the requests that contain the data the preferred approach and suggests a headless browser when those requests are hard to reproduce.
What Headless Browsers Are Used For
Scraping is only one use. Others include:
- Automated testing: running end-to-end tests and JavaScript library test suites without opening a window.
- Screenshots and PDFs: headless Chrome can capture a page with the
--screenshotflag or save it with--print-to-pdf. - Unattended automation: running browser tasks on servers or in CI pipelines, where there is no display.
How Sites Detect Headless Browsers
The W3C WebDriver standard defines navigator.webdriver so a browser can tell a page it is under automation. Chrome sets it to true when it runs with the --headless or --enable-automation flag, and Firefox sets it when Marionette is enabled. Sites can also compare the browser's other signals, as in browser fingerprinting.
Proxy Settings Work Differently in a Headless Browser
A proxy URL that works in curl, such as http://user:pass@host:port, doesn't work the same way in Chrome.
- Credentials go in separately: Chrome won't use credentials embedded in its proxy settings. Puppeteer takes them through
page.authenticate(), and Playwright has separate username and password fields for HTTP(S) proxies. - Chrome can't log in to a SOCKS5 proxy: Chrome supports no authentication methods for SOCKSv5, so a SOCKS5 proxy that needs a username and password won't work directly. HTTP proxies support Basic, Digest, Negotiate, and NTLM.
- DNS can still leak: with HTTP or SOCKS5 proxies, Chrome resolves page hostnames on the proxy side. For SOCKS5, Chromium's docs note that DNS prefetching can still send local lookups, and recommend
--host-resolver-rulesto block them. - One proxy per context: Playwright can set a proxy for the whole browser or for each browser context, so one browser can run several sessions through different proxies.
What It Means for Web Scraping
- Budget for the whole page: in July 2025, the median home page weighed 2.56 MB on mobile and made a median of 75 requests, according to the HTTP Archive. A headless browser fetches all of it through your proxy unless you block images and media you don't need.
- Pick the lighter tool first: if the data comes from an API call or plain HTML, an HTTP client is cheaper and faster.
- Keep each session together: use one browser context per proxy and session, so cookies and IP stay matched.