Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To capture a website from a Node.js server with Puppeteer, launch a browser, open a page, navigate to the target URL, and call page.screenshot(). Choose the screenshot options based on whether you need the visible viewport, the full document, a cropped region, or one element. In a server handler, close the browser in a finally block so errors do not leave browser processes behind.

Minimal Puppeteer screenshot flow

The example below uses ECMAScript modules and saves a PNG to disk. Install Puppeteer in your Node project with npm install puppeteer; the package downloads a compatible browser by default. This uses the current Puppeteer documentation version, 25.12.0, as shown on the cited API pages.

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
try {
  const page = await browser.newPage();
  await page.goto('https://example.com', { waitUntil: 'networkidle2' });
  await page.screenshot({ path: 'capture.png', type: 'png' });
} finally {
  await browser.close();
}

The lifecycle—launch, create a page, navigate, capture, then close—is the pattern in Puppeteer’s Page API example. The screenshot guide demonstrates networkidle2 as a navigation condition, but it does not guarantee that every site’s application content is ready. See the screenshots guide.

For CommonJS projects, use const puppeteer = require('puppeteer'); and place the asynchronous work inside an async function. The ESM example is directly runnable in a project configured for modules.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Return screenshot bytes from a Node API

Without a path, page.screenshot() returns image data rather than writing a file. Its default output is a Uint8Array; you can pass those bytes to an HTTP response or store them. For example, with Express:

import express from 'express';
import puppeteer from 'puppeteer';

const app = express();

app.get('/screenshot', async (req, res) => {
  const url = typeof req.query.url === 'string' ? req.query.url : '';
  if (!url) return res.status(400).send('Provide a url query parameter.');

  let browser;
  try {
    browser = await puppeteer.launch();
    const page = await browser.newPage();
    await page.goto(url, { waitUntil: 'networkidle2' });
    const bytes = await page.screenshot({ type: 'png' });
    res.type('png').send(Buffer.from(bytes));
  } catch (error) {
    res.status(502).send('Could not capture the requested page.');
  } finally {
    if (browser) await browser.close();
  }
});

app.listen(3000);

This minimal handler accepts a URL from the caller. In a real service, validate and restrict destinations before navigating: an endpoint that can fetch arbitrary URLs may expose internal services or files. That is a general server-security concern, not a Puppeteer option.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

If the consumer specifically requires JSON, request base64 output with encoding: 'base64' and serialize the returned string. For a binary image endpoint, bytes with an image content type avoid the base64 representation; this is an API-design choice, not a measured Puppeteer speed claim. See Page.screenshot().

Choose the capture area

What to capture How When to use it
Visible viewport Default screenshot behavior Capture only the currently visible browser area.
Whole document { fullPage: true } Capture the page beyond the viewport height.
Specific rectangle { clip: { x, y, width, height } } Crop a known region of the rendered page.
One element Find it, then call element.screenshot() Capture a rendered component such as a chart or card.

For a clipped capture, all rectangle values must describe the area you intend to capture. For an element capture, wait for the selector first so the handle exists. Puppeteer’s guide says element screenshots scroll the element into view by default if it is hidden.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
const page = await browser.newPage();
await page.goto('https://example.com', { waitUntil: 'networkidle2' });

// Entire document
await page.screenshot({ path: 'full.png', fullPage: true });

// A rectangle in the page
await page.screenshot({
  path: 'region.png',
  clip: { x: 20, y: 100, width: 640, height: 360 }
});

// One rendered element
const card = await page.waitForSelector('.product-card');
await card.screenshot({ path: 'card.png' });

Option names and element behavior are documented in the screenshots guide and ScreenshotOptions.

Select format, quality, and destination

  • PNG: the default format, suitable when you want lossless image output or transparency.
  • JPEG: use type: 'jpeg' for a JPEG. The quality option ranges from 0 to 100 and applies to formats where quality is meaningful, not PNG.
  • Transparent background: use omitBackground: true when the page background should be omitted.
  • File or returned data: setting path writes a file; Puppeteer can infer the output type from the path extension. With no path, it returns image data instead.
  • Base64: set encoding: 'base64' when a string is required, such as for a JSON payload.
await page.screenshot({
  path: 'transparent.webp',
  type: 'webp',
  omitBackground: true
});

The supported option descriptions and defaults are listed in the ScreenshotOptions reference. Check the installed Puppeteer version’s API if you depend on a particular format or option.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Wait for the page that actually needs to be captured

waitUntil: 'networkidle2' is a useful starting point, and appears in the official screenshot example. It is not a universal readiness test: a page can render late content after network activity quiets, and pages with persistent requests may not reach the condition promptly. When a specific component determines whether the result is usable, wait for that selector instead:

await page.goto('https://example.com', { waitUntil: 'domcontentloaded' });
await page.waitForSelector('#report-ready');
await page.screenshot({ path: 'report.png', fullPage: true });

Use a site-specific ready marker or other known application condition when one is available. A fixed delay can help with a known animation or delayed transition, but it is less precise than waiting for the content the capture needs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Manage browser resources and server workload

Close the browser whether navigation or capture succeeds or throws; the try/finally examples above provide that guarantee. Starting a fresh browser for every request is straightforward but may not suit a high-volume service. Browser reuse, context isolation, concurrency limits, memory budgets, and deployment platform should be chosen and tested against your own workload: Puppeteer’s reviewed documentation does not establish a general safe throughput or recommended pool configuration.

For shared BrowserContexts, Puppeteer documents that opening a new page or closing a page waits while a screenshot is in progress; bringToFront() does not wait. Avoid assuming that operations on a shared page are independent when captures overlap. See Page.screenshot().

Troubleshooting captures

  • The screenshot is blank or incomplete: navigation completion may precede application readiness. Wait for the content selector or a page-specific ready condition before capturing.
  • The capture ends at the viewport: add fullPage: true for the whole document; the default is a viewport capture.
  • The element is missing: ensure its selector matches the rendered page and wait for it with page.waitForSelector() before calling screenshot() on the handle.
  • The file was not created: provide a path. Without one, Puppeteer returns image data rather than saving a file.
  • A quality setting has no effect: quality applies to supported lossy formats such as JPEG, not PNG.
  • The server accumulates browser processes: close the browser in a finally block, including on navigation and screenshot errors.
  • Navigation appears to hang on network idle: a page may keep network requests active. Use a different navigation condition and then wait for the application element or state that matters.

Or skip the browser setup

If you need screenshots through an API rather than running Chromium in your service, ScreenshotNeo accepts one GET request and returns an image or PDF. Its cURL example saves a WebP capture:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

See the ScreenshotNeo API documentation for request options. Cookie banners are accepted and removed before capture, along with known consent platforms, newsletter popups, and chat widgets; each cleanup step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and the response includes page-verdict and billing headers. An MCP server provides take_screenshot, get_page_info, and capture_pdf for AI agents. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up free for ScreenshotNeo.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently Asked Questions

Can Puppeteer return a screenshot without saving it to disk?

Yes. Omit the path option and use the returned image bytes; request encoding: 'base64' if you specifically need a string.

Does Puppeteer require a separate screenshot service?

No. Puppeteer drives a browser locally or on your server, and its Page.screenshot() method produces the capture.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.