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.

Headless Browser Tools and When to Use Them

Puppeteer, Playwright and Selenium each offer programmatic control over navigation, clicking, form filling, and waiting for dynamic content to load. 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 --screenshot flag or save it with --print-to-pdf.
  • Unattended automation: Running browser tasks on servers or in CI pipelines, where there is no display.

How a Headless Browser Is Controlled

You start the browser in headless mode, then send it commands from a script. Chrome runs headless with the --headless flag. Puppeteer launches Chrome or Firefox headless by default and controls it over the Chrome DevTools Protocol or WebDriver BiDi. Selenium uses the W3C WebDriver standard. The script tells the browser which pages to open and what to do on them, then reads back the result.