Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon 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 desk5 min

How to Set the Puppeteer Viewport for Screenshots

Use and await Puppeteer’s page.setViewport() before navigation to control screenshot dimensions. Learn CSS pixels, device scale, mobile emulation, full-page capture, and troubleshooting.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Call and await page.setViewport() before navigating, then take the screenshot. The viewport’s width and height are measured in CSS pixels; use fullPage: true separately when you want the whole document rather than just the visible viewport.

Set the viewport before navigating

Create a page, set its viewport, navigate to the target, and capture it:

As an Amazon Associate I earn from qualifying purchases.

const page = await browser.newPage();
await page.setViewport({
  width: 1280,
  height: 800,
  deviceScaleFactor: 1,
});
await page.goto('https://example.com');
await page.screenshot({ path: 'page.png' });

setViewport() returns a promise, so await it before goto(). Puppeteer advises setting the viewport before navigation because some sites do not expect the screen size to change after loading; setting mobile or touch emulation can reload a page in some cases. See the Page.setViewport() documentation.

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

This sets the page’s emulated viewport, not the operating system’s browser-window dimensions. For ordinary screenshot sizing, use setViewport(), not window-management APIs.

#1 Best Overall
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB | 1920×1080 LED Monitor, 4ms GtG, Adaptive Sync, HDMI 1.4, Tilt Adjust, Low Blue Light, 4yr Advance Replacement Warranty
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents

Choose dimensions and device behavior

Width and height

Both values are required and expressed in CSS pixels. Pick dimensions that correspond to the layout you want to inspect—for example, a desktop width or a width around the responsive breakpoint you are checking. The browser then renders the page for that viewport.

Device pixel ratio

deviceScaleFactor controls pixel density, not the CSS layout width. It defaults to 1. Leave it at 1 for standard output; increase it when you need a higher-density image. A zero value for width, height, or deviceScaleFactor resets that property to its system default, so use explicit positive values for reproducible captures. Viewport fields and defaults are documented in Puppeteer’s Viewport API.

Mobile viewport and touch

Set isMobile: true when you need the page to honor its meta viewport tag. Set hasTouch: true when the viewport should support touch events. These flags do not, by themselves, apply a particular device’s complete metrics and user agent.

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
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB | 1920×1080 LED Monitor, 4ms GtG, Adaptive Sync, HDMI 1.4, Tilt Adjust, Low Blue Light, 4yr Advance Replacement Warranty
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
await page.setViewport({
  width: 390,
  height: 844,
  deviceScaleFactor: 1,
  isMobile: true,
  hasTouch: true,
});

Known-device emulation

If the user agent should match a Puppeteer-known device as well as its viewport metrics, use page.emulate() before navigation. For example:

const { KnownDevices } = require('puppeteer');
const page = await browser.newPage();
await page.emulate(KnownDevices['iPhone 17 Pro']);
await page.goto('https://example.com');
await page.screenshot({ path: 'mobile.png' });

page.emulate() is a shortcut for setting the user agent and viewport. Available device names and metrics can change across Puppeteer releases; use a device listed by the version installed in your project. See Page.emulate().

Capture the visible viewport or the full page

Setting the viewport dimensions does not automatically capture the entire document. By default, fullPage is false, so a screenshot captures the visible area. Set it to true for a full-page image:

Rank #3
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.
await page.screenshot({ path: 'full-page.png', fullPage: true });

For a selected region, use the screenshot clip option. captureBeyondViewport controls capture beyond the viewport; the API documents its default as false without a clip and true when a clip is supplied. Other useful options include omitBackground for transparency and type and quality for output format. Quality from 0 to 100 applies to supported lossy formats, not PNG. When a path is supplied, its extension determines the image type; without a path, Puppeteer returns the image data instead of saving a file. Refer to the current ScreenshotOptions API for the complete option details.

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

Wait for the page content you need

A screenshot records the page state at capture time. The official guide demonstrates waiting for networkidle2, but network idle is not a universal guarantee that every image, animation, or client-rendered component is ready. Choose a wait that matches the page:

  • Wait for a meaningful selector when a specific component must appear.
  • Use a deliberate delay only when the page has timed visual updates that cannot be detected by a selector.
  • For lazy-loaded content in a full-page capture, ensure the page has loaded the content you expect before taking the screenshot.

Puppeteer’s guide also supports capturing a particular element with ElementHandle.screenshot(); it attempts to scroll a hidden element into view. See the Puppeteer screenshots guide.

Rank #4
Sale
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor | 100Hz, Game Mode, Advanced Eye Comfort, HDMI and D-sub Ports (LS27D366GANXZA)
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient

Configure a default viewport or check the current setting

You can set defaultViewport in browser connection options to apply a viewport to each page; the documented default is 800 by 600. For a one-off page size or when different pages need different sizes, call page.setViewport() on the individual page.

page.viewport() returns the configured viewport setting. It does not verify the page’s actual rendered viewport. To reset a page to its default viewport, call:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
await page.setViewport(null);

See the ConnectOptions API and Page.viewport() API.

Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot viewport and screenshot issues

  • The page has the wrong responsive layout: Set and await the viewport before page.goto(). Check that width and height are CSS pixels, and that they cross the breakpoint you intend to test.
  • The image is larger than expected: The viewport is in CSS pixels, while deviceScaleFactor affects output pixel density. Check both values.
  • The screenshot stops at the visible area: Add fullPage: true; the viewport dimensions alone do not request a full-document capture.
  • Mobile rendering does not match a device: isMobile and hasTouch control specific behavior, but do not set a device user agent. Use page.emulate(KnownDevices[...]) when you need device metrics and user agent together.
  • Content is missing or still changing: Wait for the relevant selector or page-specific readiness condition before capture. Do not assume network idle means every visual asset or animation is finished.
  • No image file appears: Supply a path to save the screenshot. Without one, the screenshot data is returned rather than written to disk.

Or skip the browser setup

If you need a screenshot without maintaining Puppeteer and browser setup, ScreenshotNeo provides a website screenshot API and MCP server. One GET request can return PNG, JPEG, WebP, or PDF; its capture options include viewport presets and custom dimensions.

Example cURL request (see the ScreenshotNeo API documentation):

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

ScreenshotNeo accepts cookie and consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each of those steps can be disabled. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, with response headers indicating the page verdict and billing status. Its MCP server offers screenshot and page-info tools for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.

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

Sign up for ScreenshotNeo’s free 1,000 screenshots per month—no card required.

Version note

The API details above reflect Puppeteer documentation version 25.12.0, retrieved October 3, 2026. Puppeteer’s API can change between releases; if behavior differs, check the documentation for the version installed in your project.

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
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

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.