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

Set Playwright’s viewport before you navigate: await page.setViewportSize({ width: 1200, height: 800 }). That width controls the page’s responsive layout. Use clip.width only when you want to crop the captured rectangle, fullPage when you need the entire scrollable height, and scale: 'css' when the output file must stay one pixel per CSS pixel.

Choose the setting that actually controls width

Playwright has several screenshot options that are often mistaken for one another. Pick the control based on the result you need:

Goal Use What it changes
Make the page render as a 1,200-pixel layout page.setViewportSize() or context viewport CSS viewport width and responsive breakpoints
Capture only a rectangle of a rendered page clip: { x, y, width, height } Visible output rectangle; it does not reflow the page
Capture the whole document vertically fullPage: true Vertical coverage, not horizontal layout width
Keep output pixels equal to CSS pixels scale: 'css' CSS-to-device-pixel conversion
Capture one component locator.screenshot() The selected element’s bounding box

The viewport should normally be configured before navigation. Setting it after the page has loaded can leave responsive scripts, images, or breakpoint-dependent components in a state that does not match a fresh visit at the target width.

Set a fixed screenshot width in JavaScript

This complete example creates a browser, sets a 1,200 by 800 CSS-pixel viewport, navigates, and saves a PNG:

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 { chromium } from 'playwright';

const browser = await chromium.launch();
const page = await browser.newPage();

await page.setViewportSize({ width: 1200, height: 800 });
await page.goto('https://example.com', { waitUntil: 'networkidle' });
await page.screenshot({ path: 'screenshot.png' });

await browser.close();

width and height are CSS pixels. The width determines which media queries and responsive layout rules run. The height determines the initial visible area; it does not limit a fullPage capture.

Set the viewport on the browser context

When several pages should share the same dimensions, define the viewport when creating the context:

import { chromium } from 'playwright';

const browser = await chromium.launch();
const context = await browser.newContext({
  viewport: { width: 1200, height: 800 }
});
const page = await context.newPage();

await page.goto('https://example.com');
await page.screenshot({ path: 'context-width.png' });

await browser.close();

Context-level configuration is useful in test fixtures and screenshot workers because every page starts with the same layout. A page-level call is convenient when one page needs a different width.

Make the screenshot exactly 1,200 output pixels wide

A 1,200-CSS-pixel viewport does not always produce a 1,200-pixel image. Playwright’s screenshot scale defaults to 'device', so a high-DPI device scale can increase the file’s pixel dimensions. Request CSS scaling for a stable one-to-one result:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
await page.screenshot({
  path: '1200-css-pixels.png',
  scale: 'css'
});

With scale: 'css', one image pixel corresponds to one CSS pixel. scale: 'device' can produce a sharper, wider bitmap on a Retina or other high-DPI configuration while leaving the CSS viewport unchanged.

Use clipping when you want a crop, not a new layout

clip controls the captured rectangle. It does not change the page’s viewport, responsive breakpoints, or element positions. The rectangle requires x, y, width, and height:

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
await page.screenshot({
  path: 'clipped.png',
  clip: { x: 0, y: 0, width: 1200, height: 800 },
  scale: 'css'
});

Use clipping for a known region such as a dashboard panel or the top portion of a page. If the content itself must reflow to 1,200 pixels, set the viewport instead. A 900-pixel viewport followed by a 1,200-pixel clip cannot create the missing 300 pixels of layout; it only clips the rendered 900-pixel page area (or an area extending beyond it).

Clip an element’s bounding box

For a component whose position changes between pages, let Playwright calculate its rectangle:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const card = page.locator('[data-testid="pricing-card"]');
await card.screenshot({
  path: 'pricing-card.png',
  scale: 'css'
});

Element screenshots are preferable to hard-coded coordinates when the target is a single component. Wait for the component to be visible and stable before capturing if its content is animated or loaded asynchronously.

Capture the full page at a chosen width

Combine the desired viewport width with fullPage: true:

import { chromium } from 'playwright';

const browser = await chromium.launch();
const page = await browser.newPage();
await page.setViewportSize({ width: 1200, height: 800 });
await page.goto('https://example.com', { waitUntil: 'networkidle' });

await page.screenshot({
  path: 'full-page.png',
  fullPage: true,
  scale: 'css'
});

await browser.close();

fullPage captures the full scrollable page instead of only the current viewport. It changes vertical coverage; it does not set horizontal width. The page still lays out at the 1,200-pixel viewport configured before navigation.

Python binding

Python uses snake_case for the equivalent option names:

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

with sync_playwright() as p:
    browser = p.chromium.launch()
    page = browser.new_page(viewport={"width": 1200, "height": 800})
    page.goto("https://example.com", wait_until="networkidle")
    page.screenshot(path="full-page.png", full_page=True, scale="css")
    browser.close()

To crop instead, pass clip={"x": 0, "y": 0, "width": 1200, "height": 800}. The underlying concepts are the same: viewport for layout, clip for cropping, full-page for height, and scale for pixel density.

Reliable width workflows

Wait for content that changes the page height

networkidle is useful for pages that finish loading through requests, but it is not a guarantee that every image, font, animation, or client-side widget has reached its final state. For deterministic captures, wait for a meaningful selector, use a deliberate delay only when necessary, and disable or finish animations in your test setup.

Load lazy content before a full-page capture

Lazy images may not exist until their sections approach the viewport. Scroll through the page or trigger the site’s lazy-load mechanism before taking a full-page screenshot, otherwise the output can contain blank image areas even though the width is correct.

Keep dimensions consistent in visual tests

Use the same viewport, browser engine, device scale, fonts, and color scheme for every baseline and comparison run. A changed device scale can make files appear wider even when the CSS viewport is identical. If your test compares raw pixels, prefer scale: 'css' and a fixed viewport.

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.

Troubleshooting screenshot width problems

“My image is wider than the viewport”

Check the screenshot’s scale and the device scale factor. The default scale: 'device' can multiply output pixels on high-DPI devices. Add scale: 'css' when the file must match CSS dimensions.

“The mobile layout appears at 1,200 pixels”

Confirm that setViewportSize runs before goto, and that no later code resets the context viewport. Also check whether the site uses a meta viewport tag or JavaScript that applies its own responsive behavior.

Rank #4
Sale
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

“fullPage did not make the screenshot wider”

That is expected. fullPage extends the capture vertically. Set the horizontal width with the page or context viewport.

“The clip is blank or cuts off content”

Verify that x, y, width, and height describe the intended coordinate space and that the rectangle intersects the rendered page. For a moving target, use locator.screenshot() instead of fixed coordinates.

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

“A full-page image has missing sections”

Wait for the relevant content, scroll to activate lazy loading, and ensure the page has not failed a bot check or timed out. A screenshot API cannot recover content that the browser never successfully rendered.

“The page changes between runs”

Freeze time-dependent UI where possible, wait for fonts and images, use a fixed timezone and locale, and capture at the same viewport and scale. Dynamic ads, chat widgets, and consent dialogs are common sources of layout shifts.

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

Performance, reliability, and cost considerations

A wider viewport can increase layout work, image decoding, and full-page bitmap memory. Very tall pages can consume substantially more memory than viewport-only captures. Use element or clipped screenshots when a full document is unnecessary, and close pages or contexts after each job.

For repeatable test artifacts, keep browser versions and viewport settings pinned. For production capture services, account for navigation timeouts, blocked resources, authentication, cookie consent, and pages that require interaction. Record whether a capture was successful rather than treating every HTTP response as a valid screenshot.

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

Or skip the browser setup

ScreenshotNeo provides a website screenshot API and MCP server. A GET request returns PNG, JPEG, WebP, or PDF, with options for viewport and device presets, full-page capture, CSS-selector elements, retina scale, custom CSS and JavaScript, waits, clicks, headers, cookies, blocking rules, resizing, caching, signed links, asynchronous jobs, bulk capture, and PDF controls. It accepts the parameter names used by other screenshot APIs, which can simplify migration.

Use the API when you do not want to maintain Playwright browser setup:

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}`);

See the ScreenshotNeo documentation for request options. Before capture, it accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing result. Its MCP server lets Claude, Cursor, and other MCP clients call take_screenshot, get_page_info, and capture_pdf. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account to start.

FAQ

Can I set only the screenshot width?

Viewport configuration always includes a height, so provide a practical height such as 800. Use clip when you need a rectangle with its own width and height.

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

Does Retina affect responsive breakpoints?

No. Device scale changes output pixel density, while the CSS viewport controls responsive layout. Use scale: 'css' for one output pixel per CSS pixel.

Which option is best for a single UI component?

Use locator.screenshot(); it follows the element’s actual bounding box instead of relying on page coordinates.

Frequently Asked Questions

Can I set only the screenshot width?

Viewport configuration always includes a height, so provide a practical height such as 800. Use clip when you need a rectangle with its own width and height.

Does Retina affect responsive breakpoints?

No. Device scale changes output pixel density, while the CSS viewport controls responsive layout. Use scale: ‘css’ for one output pixel per CSS pixel.

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

Which option is best for a single UI component?

Use locator.screenshot(); it follows the element’s actual bounding box instead of relying on page coordinates.

The Bottom Line

Set the viewport before navigation to control Playwright’s rendered width. Add scale: 'css' for predictable output pixels, use clip for cropping, and use fullPage only for extra vertical coverage.

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.