Headless Chrome Node.js API



Build status npm puppeteer package

Puppeteer is a Node.js library which provides a high-level API to control

Chrome/Chromium over the

Puppeteer runs in

mode by default, but can be configured to run in full (non-headless)


What can I do?

Most things that you can do manually in the browser can be done using Puppeteer!
Here are a few examples to get you started:

- Generate screenshots and PDFs of pages.
- Crawl a SPA (Single-Page Application) and generate pre-rendered content (i.e.
  "SSR" (Server-Side Rendering)).
- Automate form submission, UI testing, keyboard input, etc.
- Create an automated testing environment using the latest JavaScript and
  browser features.
- Capture a
  of your site to help diagnose performance issues.
- Test Chrome Extensions.

Getting Started


To use Puppeteer in your project, run:

  1. ``` sh
  2. npm i puppeteer
  3. # or `yarn add puppeteer`
  4. # or `pnpm i puppeteer`
  5. ```

When you install Puppeteer, it automatically downloads a recent version of
Chromium (170MB macOS, 282MB Linux, ~280MB Windows) that is
with Puppeteer. For a version of Puppeteer without installation, see


Puppeteer uses several defaults that can be customized through configuration

For example, to change the default cache directory Puppeteer uses to install
browsers, you can add a .puppeteerrc.cjs (or puppeteer.config.cjs) at the
root of your application with the contents

  1. ``` js
  2. const {join} = require('path');

  3. /**
  4. * @type {import("puppeteer").Configuration}
  5. */
  6. module.exports = {
  7.   // Changes the cache location for Puppeteer.
  8.   cacheDirectory: join(__dirname, '.cache', 'puppeteer'),
  9. };
  10. ```

After adding the configuration file, you will need to remove and reinstall
puppeteer for it to take effect.

See the configuration guide for more


Every release since v1.7.0 we publish two packages:

- [puppeteer](https://www.npmjs.com/package/puppeteer)
- [puppeteer-core](https://www.npmjs.com/package/puppeteer-core)

puppeteer is a _product_ for browser automation. When installed, it downloads
a version of Chromium, which it then drives using puppeteer-core. Being an
end-user product, puppeteer automates several workflows using reasonable

puppeteer-core is a _library_ to help drive anything that supports DevTools
protocol. Being a library, puppeteer-core is fully driven through its
programmatic interface implying no defaults are assumed and puppeteer-core
will not download Chromium when installed.

You should use puppeteer-core if you are
If you are managing browsers yourself, you will need to call
[puppeteer.launch](https://pptr.dev/api/puppeteer.puppeteernode.launch) with
an an explicit
(or [channel](https://pptr.dev/api/puppeteer.launchoptions.channel) if it's
installed in a standard location).

When using puppeteer-core, remember to change the import:

  1. ```ts
  2. import puppeteer from 'puppeteer-core';
  3. ```


Puppeteer follows the latest
maintenance LTS version of

Puppeteer will be familiar to people using other browser testing frameworks. You
create some
pages, and then manipulate them with

For more in-depth usage, check our guides


The following example searches
tagged "Headless Chrome" and scrape results from the results page.

  1. ```ts
  2. import puppeteer from 'puppeteer';

  3. (async () => {
  4.   const browser = await puppeteer.launch();
  5.   const page = await browser.newPage();

  6.   await page.goto('https://developers.google.com/web/');

  7.   // Type into search box.
  8.   await page.type('.devsite-search-field', 'Headless Chrome');

  9.   // Wait for suggest overlay to appear and click "show all results".
  10.   const allResultsSelector = '.devsite-suggest-all-results';
  11.   await page.waitForSelector(allResultsSelector);
  12.   await page.click(allResultsSelector);

  13.   // Wait for the results page to load and display the results.
  14.   const resultsSelector = '.gsc-results .gs-title';
  15.   await page.waitForSelector(resultsSelector);

  16.   // Extract the results from the page.
  17.   const links = await page.evaluate(resultsSelector => {
  18.     return [...document.querySelectorAll(resultsSelector)].map(anchor => {
  19.       const title = anchor.textContent.split('|')[0].trim();
  20.       return `${title} - ${anchor.href}`;
  21.     });
  22.   }, resultsSelector);

  23.   // Print all the files.
  24.   console.log(links.join('\n'));

  25.   await browser.close();
  26. })();
  27. ```

Default runtime settings

1. Uses Headless mode

Puppeteer launches Chromium in
To launch a full version of Chromium, set the
option when launching a browser:

  1. ```ts
  2. const browser = await puppeteer.launch({headless: false}); // default is true
  3. ```

2. Runs a bundled version of Chromium

By default, Puppeteer downloads and uses a specific version of Chromium so its
API is guaranteed to work out of the box. To use Puppeteer with a different
version of Chrome or Chromium, pass in the executable's path when creating a
Browser instance:

  1. ```ts
  2. const browser = await puppeteer.launch({executablePath: '/path/to/Chrome'});
  3. ```

You can also use Puppeteer with Firefox Nightly (experimental support). See
[Puppeteer.launch](https://pptr.dev/api/puppeteer.puppeteernode.launch) for
more information.

[this article](https://www.howtogeek.com/202825/what%E2%80%99s-the-difference-between-chromium-and-chrome/)
for a description of the differences between Chromium and Chrome.
[This article](https://chromium.googlesource.com/chromium/src/+/refs/heads/main/docs/chromium_browser_vs_google_chrome.md)
describes some differences for Linux users.

3. Creates a fresh user profile

Puppeteer creates its own browser user profile which it cleans up on every

Using Docker

See our Docker guide.

Using Chrome Extensions



Check out our contributing guide to get an
overview of Puppeteer development.


Our FAQ has migrated to