Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk3 min

How to Capture a Specific Area with a Puppeteer Screenshot Clip

Use Puppeteer’s clip coordinates for a rectangular screenshot, or capture a selected DOM element with ElementHandle.screenshot().

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.

Use page.screenshot({ clip: { x, y, width, height } }) to capture a rectangular area, or call screenshot() on an element handle when the area is a specific DOM element. The examples below follow Puppeteer 25.12.0 documentation.

Capture a rectangle with clip

Set x and y to the rectangle’s top-left coordinates, then provide its width and height. These example values need to be adjusted to the page and area you want to capture.

As an Amazon Associate I earn from qualifying purchases.

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

clip describes a page region. Its type, ScreenshotClip, extends BoundingBox and includes an optional scale that defaults to 1. The screenshot option captureBeyondViewport defaults to false when no clip is set and true when one is set; a clip therefore does not by itself mean capture is limited to the visible viewport.

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

Capture a specific DOM element

If the target is a single element identified by a selector, use an element handle’s screenshot() method instead of calculating rectangle coordinates manually.

const element = await page.waitForSelector('.target');
await element.screenshot({ path: 'element.png' });

Puppeteer’s guide says that, by default, ElementHandle.screenshot() tries to scroll the element into view if it is hidden. This method is useful when the target is represented by one DOM node; use a page clip for a geometric area that is not.

Choose the capture target

Need Use Why
A rectangle defined by coordinates page.screenshot({ clip }) Set the region’s x, y, width and height.
A particular DOM node ElementHandle.screenshot() Capture the selected element without manually specifying a rectangle.

Save or consume the screenshot

Providing path writes the image to disk, and Puppeteer infers the image format from the file extension. PNG is the default. Without a path, Page.screenshot() returns image data as a Promise<Uint8Array>; the base64 encoding overload returns a string. JPEG quality can be set from 0 to 100. The quality option does not apply to PNG.

Troubleshoot common issues

  • The captured region is misplaced or the wrong size: Recheck the clip’s coordinates and dimensions against the page you are capturing. The sample numbers are illustrative, not universal.
  • The screenshot includes content beyond the visible viewport: A clip changes the default for captureBeyondViewport to true. Set that option explicitly if you need different behavior.
  • No file appears: Confirm that you supplied a path. Without one, the screenshot data is returned to your code rather than saved automatically.
  • A selected element is not initially visible: ElementHandle.screenshot() attempts to scroll a hidden element into view by default. Ensure the selector resolves to the element you intend to capture.
  • JPEG quality has no effect: The quality setting does not apply to PNG; use an appropriate output format if you need JPEG quality control.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If you need a screenshot without writing and running Puppeteer capture code, ScreenshotNeo can return an image or PDF through one GET request. Cookie banners are accepted and removed along with supported popups and chat widgets before the shot; those steps can be turned off. Bot checks, blank pages, failed loads and cache hits are not billed, with response headers reporting the page verdict and billing status. ScreenshotNeo also provides an MCP server for AI agents, and includes 1,000 shots a month free with no card; paid plans start at $5 for 3,000 shots. See the ScreenshotNeo API documentation.

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

Sign up for 1,000 free screenshots a month, with no card required.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.