Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk5 min

How to Resize a Page with Puppeteer: Viewport vs. Browser Window

Use setViewport() for responsive page dimensions; use the experimental page.resize() method for browser-window content sizing. See code and measurement guidance.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To change a page’s responsive viewport in Puppeteer, use await page.setViewport({ width, height }), preferably before navigating. To resize the browser window so the page’s content area has specific dimensions, clear the default viewport with await page.setViewport(null) and use page.resize({ contentWidth, contentHeight }). That window-resize method is experimental, so check support in your installed Puppeteer version.

Choose what you need to resize

“Page size” can mean the viewport the site uses for responsive layout, or the browser window’s content area. These are separate controls: setViewport() configures page viewport dimensions; resize() targets the browser window’s content dimensions. The latter is documented as experimental. Puppeteer’s v25.12.0 API documentation covers the viewport method, and its window-management guide shows content sizing.

As an Amazon Associate I earn from qualifying purchases.

Set a responsive viewport

Set the viewport before navigation when possible. Puppeteer notes that some websites do not expect phone-size changes; changing isMobile or hasTouch can also reload the page. The official API example follows this order.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
try {
  const page = await browser.newPage();
  await page.setViewport({
    width: 640,
    height: 480,
    deviceScaleFactor: 1,
  });
  await page.goto('https://example.com');
  console.log(await page.evaluate(() => ({
    width: window.innerWidth,
    height: window.innerHeight,
  })));
} finally {
  await browser.close();
}

setViewport() accepts a viewport object or null and returns a promise, so await it. The example uses a 640-by-480 CSS-pixel viewport and a scale factor of 1; change these values to match the layout you want to test.

#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

Use a device preset when needed

If you need a particular device’s user agent as well as its viewport, use page.emulate(device). Puppeteer describes this as a shortcut for setting both. Emulate before navigation when possible, especially if the site may behave differently when it detects a phone. The cited API result identifies Puppeteer v25.11.0. See the emulate API reference.

Resize the browser window’s content area

Use this approach when the browser window itself must have a chosen content width and height, rather than merely emulating a viewport. The documented sequence removes the default viewport constraint, requests the resize, waits for the browser’s resize event, and then reads the resulting dimensions.

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
import puppeteer from 'puppeteer-core';

const browser = await puppeteer.launch({
  args: ['--screen-info={800x600}'],
});
try {
  const page = (await browser.pages())[0];

  // Let the browser window determine the content area size.
  await page.setViewport(null);

  // Register the listener before requesting the asynchronous resize.
  const resized = page.evaluate(() => new Promise(resolve => {
    window.addEventListener('resize', resolve, { once: true });
  }));

  await page.resize({ contentWidth: 600, contentHeight: 400 });
  await resized;

  const dimensions = await page.evaluate(() => ({
    innerWidth: window.innerWidth,
    innerHeight: window.innerHeight,
    outerWidth: window.outerWidth,
    outerHeight: window.outerHeight,
  }));
  console.log(dimensions);
} finally {
  await browser.close();
}

The API marks Page.resize experimental, so verify that your installed version and runtime support it before relying on it. Check its API reference. In the official guide’s example environment, the reported inner dimensions are 600×400 and outer dimensions 600×487; the outer size depends on the environment and is not a universal browser-chrome allowance. See the guide.

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.

Measure the result, not just the setting

page.viewport() returns the last configured viewport or the connection’s defaultViewport; it does not verify the page’s live dimensions. For a window resize, wait for the resize event and inspect browser values such as window.innerWidth and window.innerHeight. The viewport API reference explains what the method reports.

Rank #3
Sale
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.

Unless configured otherwise, ConnectOptions.defaultViewport applies to each page and defaults to 800×600. Setting the viewport to null removes that default viewport constraint in the window-management example. See the ConnectOptions reference.

Keep screen size and screenshot scope separate

Headless Chrome’s screen defaults to 800×600 unless configured with --window-size; --screen-info is headless-only. Headful Chrome uses the platform’s physical screens. Screen geometry is separate from a page’s viewport. Puppeteer’s window-management guide documents these distinctions.

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

If the goal is a full-page screenshot, request fullPage: true instead of enlarging the viewport just to capture beyond the visible area. Clipping and capture beyond the viewport are separate screenshot controls. See the screenshot options reference.

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

Troubleshooting

  • The layout did not change: confirm you called and awaited page.setViewport() on the page you navigate, and that the width and height are the intended viewport dimensions.
  • The page reloaded after resizing: this can happen when changing isMobile or hasTouch. Configure those values before navigation where practical. Puppeteer documents this behavior.
  • page.resize is missing or fails: it is experimental and may not be supported by the installed version or runtime. Check the API reference for the version in use; use setViewport() instead if you only need responsive rendering.
  • The measured dimensions seem stale: do not treat page.viewport() as a live measurement. For window sizing, attach a one-time resize listener before calling page.resize(), then evaluate window.innerWidth and window.innerHeight.
  • The outer window dimensions differ from the requested content size: contentWidth and contentHeight target the content area, not the entire outer window. Browser chrome and runtime environment affect outer measurements.
  • A full-page screenshot is still cut off: use the screenshot’s fullPage option or the relevant clipping controls; viewport resizing alone is not the full-page capture setting.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

For an image or PDF without managing a Puppeteer browser session, ScreenshotNeo accepts a URL in one API request. Cookie banners are accepted and removed before capture, and known consent platforms, newsletter popups, and chat widgets can be removed; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, with verdict and billing details in response headers. An MCP server lets AI agents use screenshot and PDF tools. The free plan includes 1,000 screenshots a month without a card; paid plans start at $5 for 3,000 shots.

Install the request dependency with python -m pip install requests, then replace the URL and API key:

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.
import requests

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

For the available parameters and response behavior, see the ScreenshotNeo API documentation. Sign up for the free plan: 1,000 screenshots a month, no card required.

Frequently Asked Questions

Which Puppeteer version is this guidance based on?

The cited setViewport, window-management, resize, and emulate references identify v25.12.0, except the emulate API result, which identifies v25.11.0. Check the documentation matching your installed version, particularly for experimental methods.

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

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
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver 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.