Run Chrome without chrome, it brings all modern web platform features provided by Chromium and the Blink rendering engine to the command line.
A headless browser is a great tool for automated testing and server environments where you don’t need a visible UI shell.
Starting Headless (CLI)
The easiest way to get started with headless mode is to open the Chrome binary from the command line. If you’ve got Chrome 59+ installed, start Chrome with the -- headless flag:
1 | chrome \ |
chrome should point to your installation of Chrome.
Command line features
In some cases, you may not need to programmatically script Headless Chrome. There are some useful command line flags to perform common tasks.
Printing the DOM
The --dump-dom flag prints document.body.innerHTML to stdout:
1 | chrome --headless --disable-gpu --dump-dom https://www.chromestatus.com/ |
Create a PDF
The --print-to-pdf flag creates a PDF of the page
1 | chrome --headless --disable-gpu --print-to-pdf https://chromestatus.com/ |
Taking screenshots
To capture a screenshot of a page, use the --screenshot flag:
1 | chrome --headless --disable-gpu --screenshot https://chromestatus.com/ |
REPL mode
The --repl flag runs Headless in a mode where you can evaluate JS expression in the browser, right from the command line:
1 | chrome --headless --disable-gpu --repl https://chromestatus.com/ |



