Tutorial · Node.js

Screenshots with Puppeteer

Puppeteer drives a headless Chrome from Node.js. Here are the screenshot recipes you need, and the problems you will run into in production.

Updated October 1, 2026 · 2 min read

Basic screenshot

npm install puppeteer
import puppeteer from "puppeteer";

const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setViewport({ width: 1280, height: 800 });
await page.goto("https://example.com", { waitUntil: "networkidle2" });
await page.screenshot({ path: "example.png" });
await browser.close();

Full page, retina and formats

await page.setViewport({ width: 1280, height: 800, deviceScaleFactor: 2 }); // retina
await page.screenshot({ path: "full.jpg", fullPage: true, type: "jpeg", quality: 80 });

Mobile devices

import { KnownDevices } from "puppeteer";

await page.emulate(KnownDevices["iPhone 13"]);
await page.goto("https://example.com");
await page.screenshot({ path: "iphone.png" });

Viewport sizes of all common devices are on the viewport sizes pages.

One element

const element = await page.waitForSelector("#pricing");
await element.screenshot({ path: "pricing.png" });
await page.addStyleTag({ content: "#onetrust-banner-sdk, .intercom-launcher { display: none !important; }" });

Problems in production

A screenshot API handles these for you; with screenshotbase the same screenshot is one request:

curl -G "https://api.screenshotbase.com/v1/take" --data-urlencode "url=https://example.com" \
  -d full_page=true -d block_cookie_banners=true -H "apikey: YOUR-API-KEY" -o example.png

Try it without code: website screenshot tool.

Frequently asked questions

How do I take a full-page screenshot with Puppeteer?

Call page.screenshot({ path: 'page.png', fullPage: true }) after the page has loaded.

Why are images missing in my Puppeteer screenshot?

They are probably lazy-loaded. Wait for the network to go idle (waitUntil: 'networkidle0') and scroll the page to the bottom before taking a full-page screenshot.

Screenshot API

Take screenshots from your code

screenshotbase renders any website in a real browser and returns the image: full page or viewport, any device size, retina, from 100+ countries, with cookie banners and ads hidden.

Read the docs

300 free screenshots every month. No credit card required.

GET https://api.screenshotbase.com/v1/take?url=https://example.com&full_page=true

# Response: the image (PNG, JPG, WebP or GIF)
curl -G "https://api.screenshotbase.com/v1/take" \
  --data-urlencode "url=https://example.com" \
  -d viewport_width=1280 -d viewport_height=800 \
  -d format=png \
  -H "apikey: YOUR-API-KEY" \
  -o screenshot.png

Keep reading

Start using our Screenshot API for free today!

Get 300 requests / month for free