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

Use Puppeteer’s page.screenshot() method with a clip object. Set the rectangle’s x, y, width, and height, then save the returned image or bytes:

await page.screenshot({ path: 'clip.png', clip: { x: 100, y: 80, width: 500, height: 300 } });

This captures the specified rectangular region instead of the whole page. The sections below show how to choose coordinates, capture a DOM element, control output, handle dynamic pages, and diagnose common failures.

Capture a rectangle with page.screenshot()

A clipped screenshot is defined by a ScreenshotClip object. It extends Puppeteer’s BoundingBox shape, so provide x, y, width, and height. The following complete Node.js script launches Chromium, waits for navigation, captures the rectangle, and writes a PNG file.

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
try {
  const page = await browser.newPage();
  await page.setViewport({ width: 1440, height: 900 });
  await page.goto('https://example.com', { waitUntil: 'networkidle2' });

  await page.screenshot({
    path: 'clip.png',
    type: 'png',
    clip: {
      x: 100,
      y: 80,
      width: 500,
      height: 300,
      scale: 1
    },
    captureBeyondViewport: true
  });
} finally {
  await browser.close();
}

Install Puppeteer with npm install puppeteer (or use the package and browser setup already present in your project). The official screenshot guide demonstrates navigating before calling page.screenshot(); its example uses waitUntil: 'networkidle2'. That wait condition is useful when you want most network activity to settle, but it is not a universal requirement: choose a readiness condition that matches the page you are capturing.

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.

What the rectangle means

  • x and y identify the rectangle’s origin.
  • width and height define its size.
  • scale is optional and defaults to 1.
  • Use positive dimensions. A zero-sized or otherwise invalid rectangle cannot produce a useful image.

Keep the viewport fixed when you need repeatable output. Coordinates are interpreted by Puppeteer according to the installed release’s screenshot API; do not assume a particular device-pixel-ratio conversion without checking the documentation that matches your version.

Clipping content outside the initial viewport

Puppeteer documents captureBeyondViewport as false by default when no clip is supplied and true by default when a clip is supplied. Set it explicitly when the result must be stable across upgrades or when your rectangle reaches beyond the visible viewport, as in the example above. This makes your intent clear instead of relying on a conditional default.

Choose the correct capture method

Need Method What it does Important behavior
A fixed rectangular crop page.screenshot({ clip }) Captures the coordinates and dimensions you provide. You must calculate and maintain the rectangle.
A particular DOM element elementHandle.screenshot() Captures the element’s rendered box. Puppeteer scrolls the element into view when necessary; a detached element causes an error.
The entire document page.screenshot({ fullPage: true }) Creates a full-page image rather than a coordinate crop. fullPage defaults to false.

Use a clip when the crop is part of a visual specification (for example, a 500-by-300 region at a known origin). Prefer an element screenshot when the target is semantic and its position changes with responsive layout, localization, or asynchronous content.

Capture an element without measuring coordinates

When the page already exposes a stable selector, let Puppeteer locate the element and take its screenshot. This avoids manually calculating a bounding rectangle.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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.
import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
try {
  const page = await browser.newPage();
  await page.goto('https://example.com/dashboard', { waitUntil: 'networkidle2' });

  const card = await page.$('[data-testid="sales-card"]');
  if (!card) {
    throw new Error('sales card was not found');
  }

  await card.screenshot({
    path: 'sales-card.png',
    type: 'png'
  });
} finally {
  await browser.close();
}

Keep the element handle close to the screenshot call. Frameworks that re-render a component can replace the node between lookup and capture; in that case, obtain a fresh handle and try again. A selector that identifies one stable component is safer than a long chain of classes generated by a CSS-in-JS system.

Control the output format and destination

Option Default or rule Use it when
path No file is written when omitted. Provide a filename when the screenshot should be saved directly to disk. The image type can be inferred from the extension.
type PNG Choose PNG, JPEG, or WebP when your installed Puppeteer release supports the format.
encoding Binary Use 'base64' when a string is easier to send through a JSON response; otherwise consume the returned binary data.
quality Not used for PNG Set a quality value for formats other than PNG when file size matters.
omitBackground false Set to true to hide the default white background and permit transparency.
fullPage false Use only for a full-document image, not a coordinate crop.
captureBeyondViewport false without a clip; documented as true with a clip Set explicitly when the rectangle can extend outside the current viewport.

Return bytes or base64 instead of a file

With no path, the screenshot method returns image data. The standard options overload returns a Uint8Array; adding encoding: 'base64' selects the base64-string overload.

const bytes = await page.screenshot({
  clip: { x: 0, y: 0, width: 640, height: 360 },
  type: 'webp'
});

// bytes is suitable for an HTTP response, object storage upload, or Buffer.from(bytes).
const base64 = await page.screenshot({
  encoding: 'base64',
  clip: { x: 0, y: 0, width: 640, height: 360 }
});

Build a reliable clipping workflow

  1. Pin the viewport. Call page.setViewport() before navigation. A responsive breakpoint can move the target and invalidate hard-coded coordinates.
  2. Navigate to the intended URL. Use an appropriate waitUntil condition. A network-idle event does not guarantee that a client-rendered chart, font, or image has finished painting.
  3. Wait for the content that defines the crop. Wait for a selector, a known application state, or a deliberate delay after your page’s own rendering signal. Do not use a long arbitrary delay when a deterministic selector is available.
  4. Measure when layout is dynamic. Evaluate the target’s bounding box immediately before capture and pass those values to clip. Re-measure after any action that can cause reflow.
  5. Make the capture options explicit. Specify the output type, path or return mode, and captureBeyondViewport rather than depending on defaults.
  6. Close the browser in a finally block. This prevents orphaned Chromium processes when navigation or screenshotting throws.

For a measured rectangle, this pattern reads the element’s box in the page and converts it to the clip fields expected by Puppeteer:

const box = await page.$eval('#invoice-total', (node) => {
  const rect = node.getBoundingClientRect();
  return { x: rect.x, y: rect.y, width: rect.width, height: rect.height };
});

await page.screenshot({
  path: 'invoice-total.png',
  clip: box,
  captureBeyondViewport: true
});

Measure and capture in the same stable page state. If an animation is still running, the box and pixels can disagree; disable the animation with page-specific CSS or wait for the application’s completed state.

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.

Troubleshooting clipped screenshots

The crop is blank or shows the wrong area

  • Verify the viewport dimensions and the rectangle’s origin. A coordinate crop is not automatically tied to a selector.
  • Wait for the component that paints the pixels, not just the initial HTML response.
  • Check whether a cookie dialog, modal, sticky header, or consent layer is covering the intended region.
  • If the rectangle lies outside the viewport, set captureBeyondViewport: true explicitly.

Images or fonts are missing

Navigation completion and network idleness do not prove that every visual asset has been decoded and painted. Wait for a specific image or component, or have the page expose a ready flag that you can await. For fonts, wait for document.fonts.ready in a page evaluation when that is appropriate for your application.

The element screenshot throws because the node was detached

A framework re-render can invalidate an ElementHandle. Query the selector again after the render and capture the new handle. Avoid retaining handles across navigations.

The file is not created

When path is omitted, Puppeteer returns data instead of writing a file. When a path is supplied, ensure the parent directory exists and that the process has write permission. Use a filename extension that matches the requested type, or set type explicitly.

The output is unexpectedly large

PNG is lossless and is the documented default. For photographic or large full-page content, choose JPEG or WebP and set quality where supported. A smaller clip, a lower scale, or a controlled viewport also reduces bytes; balance that against the detail your reader needs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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

Code behaves differently after a Puppeteer upgrade

The reviewed official references are labeled Puppeteer versions 25.10.0 through 25.12.0. Screenshot defaults and option behavior are release-sensitive, so check the documentation matching the version in your lockfile. Keep explicit options in production code and add a visual regression check when upgrading.

Performance, reliability, and cost considerations

Performance

  • Reuse a browser process for multiple pages or captures when your workload permits, but isolate pages so cookies and application state do not leak between jobs.
  • Clip only the region you need. A full-page image can require more layout, rasterization, memory, and transfer time than a small rectangle.
  • Use a selector wait or application-ready signal rather than an unnecessarily long fixed delay.
  • Choose WebP or JPEG for bandwidth-sensitive pipelines; retain PNG when lossless edges, text, or transparency are important.

Reliability

  • Use a deterministic viewport, URL, locale, timezone, and authentication state for repeatable results.
  • Record the URL, Puppeteer version, clip values, output type, and wait condition with each job so a mismatch can be diagnosed.
  • Retry navigation failures cautiously. Repeating a screenshot after a detached-element error without re-querying the element will not fix the cause.
  • Set an outer job timeout and always close the page or browser in cleanup code.

Cost

Self-hosting Puppeteer means accounting for Chromium CPU, memory, storage, and execution time. The screenshot API itself has no separate Puppeteer charge, but your infrastructure and any browser-running service still incur their own costs. Measure your workload’s concurrency and image sizes before choosing a deployment model.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

ScreenshotNeo provides a website screenshot API and MCP server for developers. One GET request returns a PNG, JPEG, WebP, or PDF. It can accept cookie and consent banners before capture and remove more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers.

For a URL capture, use the API documented at https://screenshotneo.com/docs/:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

ScreenshotNeo also supports capturing one element by CSS selector, full-page captures with lazy images loaded, custom CSS and JavaScript, clicks before capture, waits for a selector, delay, or network idle, device presets and arbitrary viewports, dark mode, retina scale, request blocking, custom headers and cookies, timezone and geolocation, transparent backgrounds, resizing, TTL-based caching, signed links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API, and an OpenAPI specification. Its parameter names are compatible with those used by other screenshot APIs, which can simplify migration. An MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients.

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.
Plan Included shots Price
Free 1,000 per month No card required
Starter 3,000 $5
Growth 15,000 $15
Pro 60,000 $39
Scale 250,000 $99
Business 1,000,000 $249

Every feature is available on every plan, and yearly billing provides two months free. If you want clipped, selector-based, or full-page captures without maintaining Chromium, the free tier includes 1,000 screenshots a month with no card. Create a free ScreenshotNeo account.

FAQ

Does an element screenshot work when the element is below the fold?

Yes. Puppeteer’s element screenshot method scrolls the target into view when needed before invoking the page screenshot operation. It still fails if the element handle has been detached from the DOM, so query it again after a framework re-render.

Which Puppeteer documentation should I use for these defaults?

Use the reference that matches the Puppeteer version installed in your project. The reviewed screenshot references are labeled 25.10.0 through 25.12.0, and screenshot option defaults can change between releases.

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

Frequently Asked Questions

Does an element screenshot work when the element is below the fold?

Yes. Puppeteer scrolls the target into view before capturing it; obtain a fresh handle if the page re-rendered and detached the original node.

Which Puppeteer documentation should I use for these defaults?

Check the reference matching the version in your lockfile. The references covered here are labeled 25.10.0 through 25.12.0, and screenshot behavior is release-sensitive.

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.