October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
browser automation

How to Set Puppeteer’s Browser Window Size (Viewport, Content, Bounds, and Screen)

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

Use the API that matches the geometry you need: call page.setViewport({width: 1080, height: 1024}) for the page viewport; use page.resize({contentWidth: 600, contentHeight: 400}) (after page.setViewport(null)) for the browser window’s content area; use browser.setWindowBounds() for actual window position, size, or state; and pass --window-size or --screen-info at launch when configuring a headless screen.

These controls are related but not interchangeable. A viewport changes layout and rendering inside a page, while browser bounds include the operating-system window and browser chrome. The examples below target Puppeteer documentation version 25.12.0, accessed September 29, 2026; API details can change, so check the linked references before upgrading.

Choose the geometry you actually want

Target Use When to choose it Important qualification
Page viewport page.setViewport() Responsive layouts, screenshots, page tests Puppeteer documents a default viewport of 800 × 600.
Browser content area page.resize() You need window.innerWidth/innerHeight to match a requested content size The Page API marks it experimental; it excludes browser UI.
Outer window bounds browser.getWindowBounds() and browser.setWindowBounds() Positioning, moving, maximizing, or sizing a visible browser window Outer dimensions include platform- and browser-dependent chrome.
Headless screen at launch --window-size, optionally --screen-info Setting screen geometry before pages open --screen-info is headless-only; headful Chrome uses physical screens.

Puppeteer’s Window management guide explicitly separates these cases. Decide whether your assertion concerns CSS pixels in the page, the content rectangle, or the operating-system window before writing code.

Set a page viewport with page.setViewport()

For most screenshot and responsive-testing jobs, this is the correct answer. It controls the page’s layout viewport, not the desktop window frame.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • 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
import puppeteer from 'puppeteer';

const browser = await puppeteer.launch({headless: true});
const page = await browser.newPage();
await page.setViewport({width: 1080, height: 1024});
await page.goto('https://example.com', {waitUntil: 'networkidle2'});
console.log(await page.evaluate(() => ({
  innerWidth: window.innerWidth,
  innerHeight: window.innerHeight,
  devicePixelRatio: window.devicePixelRatio
})));
await page.screenshot({path: 'viewport.png', fullPage: false});
await browser.close();

The getting-started guide shows the same form of call; see Puppeteer’s getting-started documentation. Width and height are CSS pixels. A high-DPI screenshot can still have more physical pixels when you use a device scale factor:

await page.setViewport({
  width: 1440,
  height: 900,
  deviceScaleFactor: 2
});

Changing the viewport can trigger media-query changes and a new layout. Set it before navigation when you want the initial page load to observe that size. If you use emulation options such as mobile or touch behavior, keep those settings consistent with the viewport you are testing.

Measure what the page received

const metrics = await page.evaluate(() => ({
  innerWidth: window.innerWidth,
  innerHeight: window.innerHeight,
  outerWidth: window.outerWidth,
  outerHeight: window.outerHeight,
  screenWidth: window.screen.width,
  screenHeight: window.screen.height
}));
console.log(metrics);

innerWidth and innerHeight are the useful values for responsive CSS. outerWidth and outerHeight describe a window and can differ by environment, especially in headful mode.

Resize the browser’s content area at runtime

If your requirement is “make the area available to the web page exactly 600 × 400,” use the experimental Page.resize API. Puppeteer’s documented sequence first removes the default viewport constraint, then resizes the content area:

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
  • 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';

const browser = await puppeteer.launch({headless: false});
const page = await browser.newPage();
await page.setViewport(null);
await page.resize({contentWidth: 600, contentHeight: 400});
await page.goto('https://example.com', {waitUntil: 'domcontentloaded'});

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

The window-management example reports innerWidth and innerHeight of 600 × 400, while that particular environment reports an outer size of 600 × 487. The extra height is not a universal constant: browser chrome, operating-system decorations, scaling, and window-manager rules change it. The API is documented as resizing the browser window so that the content area has the requested dimensions, not as a way to specify outer bounds. See the Page API reference for the experimental label and current signature.

When this method is appropriate

  • Use it when an application’s behavior depends on the actual content rectangle in a visible browser.
  • Do not use it merely to request a screenshot width; setViewport is simpler and more predictable for that purpose.
  • Expect availability and behavior to evolve because the method is experimental.

Control outer window bounds and state

To move, resize, minimize, maximize, or otherwise control the browser window itself, obtain its window ID and call the browser-level bounds methods. This is distinct from a page viewport.

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch({headless: false});
const page = await browser.newPage();
const windowId = await page.evaluate(() => {
  // The browser exposes the target's window through the DevTools protocol.
  return null;
});

In current Puppeteer window-management examples, the page’s browser context supplies a window ID, which is then passed to browser.getWindowBounds(windowId) and browser.setWindowBounds(windowId, bounds). A complete pattern is:

const client = await page.createCDPSession();
const {windowId} = await client.send('Browser.getWindowForTarget');
const before = await browser.getWindowBounds(windowId);
console.log('before:', before);

await browser.setWindowBounds(windowId, {
  left: 40,
  top: 40,
  width: 1200,
  height: 800,
  windowState: 'normal'
});

console.log('after:', await browser.getWindowBounds(windowId));

The bounds object can contain left, top, width, height, and windowState, as shown in the official window-management guide. Set a normal state before applying explicit dimensions if the window is maximized or minimized. Platform window managers may clamp coordinates or dimensions, so verify the returned bounds rather than assuming the request was applied exactly.

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

Set headless screen dimensions at launch

Launch arguments configure the screen available to a headless browser before pages are created. Puppeteer’s screen-configuration guide says the default headless screen is 800 × 600 when --screen-info is absent. If you provide --window-size, the headless screen is as large as the requested window size.

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch({
  headless: true,
  args: ['--window-size=1365,768']
});
const page = await browser.newPage();
await page.goto('https://example.com');
console.log(await page.evaluate(() => ({
  innerWidth: window.innerWidth,
  innerHeight: window.innerHeight,
  screenWidth: window.screen.width,
  screenHeight: window.screen.height
})));
await browser.close();

args is the LaunchOptions field for extra browser command-line arguments; see LaunchOptions. The --screen-info switch is headless-only. In headful Chrome, physical monitors and the operating system determine available screens, so do not treat --screen-info as a headful monitor configuration.

Viewport versus launch size

A launch window size does not replace an explicit page viewport in every configuration. If a fixed viewport is configured, it can remain the effective page viewport even when the underlying screen is larger. For deterministic tests, set the viewport explicitly and use launch arguments only when the screen itself matters.

A practical decision procedure

  1. Define the assertion. If you are testing breakpoints or taking a fixed-width image, choose viewport dimensions.
  2. Need the page content rectangle in a visible browser? Clear the viewport with page.setViewport(null), then use page.resize, accepting its experimental status.
  3. Need position, maximize/minimize state, or outer dimensions? Obtain the window ID and use browser.setWindowBounds.
  4. Need geometry before navigation in headless mode? Pass --window-size; add --screen-info only for headless screen configuration.
  5. Verify. Read innerWidth, innerHeight, outerWidth, and screen values from the page, and read returned window bounds when controlling the browser window.

Common failures and fixes

The screenshot is the wrong width

Cause: a viewport was never set, or another emulation call replaced it. Fix: call page.setViewport after creating the page and before navigation, then log window.innerWidth.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • 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

page.resize is undefined or rejected

Cause: the installed Puppeteer version differs from the documentation version, or the method is unavailable in that release. Fix: check the Page API for your installed version; use setViewport for page geometry or browser bounds APIs for a visible window.

innerWidth is not the requested content width

Cause: the default viewport constraint is still active, the page was resized before the target page existed, or the window manager adjusted the request. Fix: create the page, call page.setViewport(null), resize it, navigate, and measure again.

Outer height differs from the requested height

Cause: browser tabs, toolbars, borders, and operating-system decorations consume space. Fix: request content dimensions with page.resize when that is the requirement, or inspect the actual bounds returned by getWindowBounds. Never hard-code the 600 × 487 outer-height example as a general conversion.

Headless and headful results disagree

Cause: headful mode uses physical platform screens and window chrome, while headless mode uses virtual screen settings. Fix: test in the same mode you deploy, set the viewport explicitly, and reserve screen flags for launch-time screen behavior.

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

Changing size appears to do nothing

Cause: the page is reporting a CSS layout that does not react at that breakpoint, or the screenshot uses fullPage, which extends height to document content. Fix: inspect computed layout and capture with fullPage: false when validating the viewport rectangle.

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

Reliability, performance, and repeatability

  • Set geometry once per page where possible. Repeated resizes can trigger multiple layouts and complicate screenshots of animations or lazy-loaded content.
  • Wait for the page state you actually test. A size change can alter responsive markup, so wait for a selector or stable network state after resizing.
  • Keep viewport, device scale factor, user agent, and mobile emulation settings in one configuration object so test runs are reproducible.
  • Use returned measurements as diagnostics in CI. Log the requested values and the observed inner*/outer* values when a visual test fails.
  • Pin or regularly review Puppeteer versions. The window-management guide and Page API identify experimental behavior that can change.

Or skip the browser setup

If your goal is a dependable website image or PDF rather than controlling Chrome interactively, ScreenshotNeo provides a single HTTP request. It accepts the consent banner like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each cleanup step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and whether it was billed.

cURL:

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)
r.raise_for_status()
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}`);
if (!res.ok) throw new Error(`${res.status} ${res.statusText}`);
const fs = await import('node:fs/promises');
await fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));

See the ScreenshotNeo API documentation for parameters and response headers. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. You can also set viewport and device presets, full-page capture, CSS-selector element capture, dark mode, retina scale, waits, custom headers and cookies, JavaScript, request blocking, geolocation, transparent backgrounds, resizing, caching TTLs, signed links, asynchronous webhooks, bulk capture for up to 100 URLs per call, usage data, and PDF options.

Every feature is available on every plan: 1,000 shots per month free with no card; Starter is $5 for 3,000, Growth $15 for 15,000, Pro $39 for 60,000, Scale $99 for 250,000, and Business $249 for 1,000,000. Yearly billing provides two months free. Create a free ScreenshotNeo account to start with the 1,000-shot allowance and no card.

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

Further reference

For the underlying APIs, consult Window management, Screen configuration, Getting started, Page, ConnectOptions, and LaunchOptions.

Frequently Asked Questions

What viewport does Puppeteer use if I do nothing?

The documented default viewport is 800 × 600. Set your own dimensions explicitly when a test or capture depends on size.

Does --screen-info configure a normal visible Chrome monitor?

No. Puppeteer documents it as headless-only; headful Chrome uses the physical screens supplied by the operating system.

Is Page.resize a stable API?

The Page API labels it experimental. Check the versioned documentation for your installed Puppeteer release before relying on it in production.

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.

Read next

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

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.