The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Set Playwright’s screenshot scale explicitly: use scale: 'css' for one output pixel per CSS pixel, or scale: 'device' for one output pixel per device pixel. Page and Locator screenshots default to 'device', while screenshot assertions default to 'css'. Making the option explicit prevents unexpected image dimensions, especially on high-DPI emulated devices.
The two screenshot scales
Playwright can rasterize a screenshot against either of the browser’s two useful pixel grids. The Page API documentation defines the options as follows:
| Setting | Output mapping | Best for |
|---|---|---|
scale: 'css' |
One image pixel for each CSS pixel in the page | Predictable layout dimensions, smaller files, visual review and storage |
scale: 'device' |
One image pixel for each device pixel | High-DPI output where you need the device’s native raster detail |
With 'device', a high-DPI context can produce an image twice as large, or larger, in each dimension than the same CSS layout captured with 'css'. That changes the bitmap dimensions and file size; it does not change the page’s CSS layout.
Set the scale on a page screenshot
Pass scale in the options object for a one-off capture:
#1 Best Overall
- 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({ viewport: { width: 1280, height: 800 } });
await page.goto('https://example.com', { waitUntil: 'networkidle' });
await page.screenshot({ path: 'page-css.png', scale: 'css', fullPage: true });
await page.screenshot({ path: 'page-device.png', scale: 'device', fullPage: true });
await browser.close();
The first file follows the CSS-pixel dimensions of the rendered page. The second preserves device-pixel density. If your pipeline compares images, stores them in an object bucket, or sends them to another service, choose one setting and keep it consistent.
Set the scale on an element screenshot
locator.screenshot() uses the same css and device values. The Locator API documents its default as device.
const card = page.locator('[data-testid="pricing-card"]');
await card.waitFor({ state: 'visible' });
await card.screenshot({
path: 'card-css.png',
scale: 'css'
});
await card.screenshot({
path: 'card-device.png',
scale: 'device'
});
Using a Locator is preferable to manually calculating an element’s bounding box because Playwright scrolls the element into view and captures the locator target. Set the scale on every call where output size matters; do not rely on the default.
Understand the defaults before changing tests
Page and Locator captures
For page.screenshot() and locator.screenshot(), the documented default is scale: 'device'. A test that previously omitted the option can therefore create larger files after a device profile or device scale factor changes.
Screenshot assertions
Playwright’s screenshot assertions use a different default: css. The PageAssertions API and TestConfig API describe this behavior. Keep assertion snapshots and manually captured artifacts on the same scale when you expect their pixel dimensions to match.
await expect(page).toHaveScreenshot('home.png', {
scale: 'css'
});
await expect(page.locator('.hero')).toHaveScreenshot('hero.png', {
scale: 'device'
});
If a snapshot suddenly reports a dimension mismatch, first check whether one side was produced by a direct screenshot (defaulting to device) and the other by an assertion (defaulting to css).
Rank #2
- 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
Screenshot scale is not device emulation
deviceScaleFactor configures the emulated device pixel ratio (DPR); the screenshot scale option selects which pixel grid is written to the image. They are related but independent controls. Playwright documents deviceScaleFactor as defaulting to 1 in browser and test options (Browser API and TestOptions API).
const context = await browser.newContext({
viewport: { width: 1280, height: 800 },
deviceScaleFactor: 2
});
const page = await context.newPage();
await page.goto('https://example.com');
// CSS-sized bitmap, despite the emulated DPR of 2:
await page.screenshot({ path: 'css-grid.png', scale: 'css' });
// Device-pixel bitmap for the same context:
await page.screenshot({ path: 'device-grid.png', scale: 'device' });
Changing deviceScaleFactor can affect media queries, canvas rendering and other device-dependent behavior. Changing scale only chooses how Playwright maps the rendered result into the output bitmap. When dimensions are not what you expect, inspect the viewport, device profile, DPR and screenshot scale together.
Choose a scale for common workflows
Visual regression tests
Use scale: 'css' for stable, portable snapshots unless your baseline intentionally represents device-pixel output. CSS scale reduces high-DPI file growth and ties the image to the layout grid. Set it explicitly on toHaveScreenshot() or in the test configuration so a future Playwright or project change cannot silently switch the convention.
Retina or print-quality assets
Use scale: 'device' when the consumer needs the extra raster detail of a high-DPI context. Confirm that downstream image dimensions, memory limits and upload quotas can accommodate the larger bitmap.
Documentation and bug reports
CSS scale is usually easier for readers to compare with DevTools measurements because one output pixel corresponds to one CSS pixel. Device scale can be useful when the bug involves anti-aliasing, canvas pixels or a device-specific rendering difference. State the viewport and DPR alongside the file so another developer can reproduce it.
Mixed pipelines
If you both save diagnostic screenshots and run snapshot assertions, define a project convention. For example, use CSS scale everywhere for review artifacts, or reserve device scale for a separate high-resolution job. Mixing defaults without documenting them is a common source of apparently “wrong” dimensions.
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #3
- 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.
Full-page, element and option examples
The scale option works with the other screenshot options; it does not replace them.
// Full page at CSS-pixel scale
await page.screenshot({
path: 'long-page.webp',
fullPage: true,
type: 'webp',
quality: 85,
scale: 'css'
});
// A single element at device-pixel scale
await page.locator('main').screenshot({
path: 'main.png',
animations: 'disabled',
caret: 'hide',
scale: 'device'
});
Wait for the same application state before either capture. A different font-loading moment, animation frame or lazy-loaded image can create visual differences that are unrelated to scale.
Troubleshooting scale and dimension problems
“My screenshot is twice as large”
Check for a high deviceScaleFactor and a call that omitted scale. Direct Page and Locator screenshots default to device. Add scale: 'css' when you want CSS-pixel dimensions.
“The assertion baseline has different dimensions”
Assertions default to css, whereas a separately generated baseline may have been captured with a direct screenshot at device. Regenerate the baseline with the same explicit scale, or set the assertion’s scale to the convention used by your artifacts.
“Changing scale changed my responsive layout”
Scale itself does not alter the viewport. Verify that you changed deviceScaleFactor, viewport size, browser project, or a device preset at the same time. Those settings can affect CSS media queries and rendering.
“The file is too large or the job runs out of memory”
Use css for review images, reduce the viewport or capture an element instead of the entire page, and avoid creating several device-scale full-page bitmaps concurrently. Keep the high-resolution variant only where it is needed.
Rank #4
- 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
“The image still differs after I set the same scale”
Scale controls pixel mapping, not page state. Compare browser version, operating system fonts, viewport, DPR, color scheme, loaded web fonts, animations, network timing and the exact URL. Disable animations and wait for a deterministic selector before capturing.
Performance, storage and reproducibility
Device scale increases the number of output pixels on high-DPI contexts, which generally increases encoding time, memory use and transfer size. CSS scale is a practical default for large regression suites and CI artifact retention. Whichever choice you make, include it in helper functions instead of scattering implicit defaults through tests.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →export async function captureCss(page, path: string) {
return page.screenshot({ path, scale: 'css', fullPage: true });
}
export async function captureDevice(page, path: string) {
return page.screenshot({ path, scale: 'device', fullPage: true });
}
Record the viewport and deviceScaleFactor with the artifact metadata. This makes a later dimension mismatch diagnosable rather than guesswork. For baselines, review diffs at the same scale used to create them; resampling an image after capture can hide real rendering changes.
Or skip the browser setup
ScreenshotNeo provides a website screenshot API when you do not want to maintain Playwright launch, fonts, browser binaries and waiting logic. It accepts a URL and returns PNG, JPEG, WebP or PDF. Its cleaning step accepts cookie and consent banners and removes more than 60 known consent platforms, newsletter popups and chat widgets before capture; each step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers.
For a CSS-like output size, choose the service’s viewport and resizing options in your request; Playwright’s scale flag itself is specific to Playwright. ScreenshotNeo also offers an MCP server with take_screenshot, get_page_info and capture_pdf tools for Claude, Cursor and other MCP clients.
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(`Screenshot failed: ${res.status}`);
const buffer = Buffer.from(await res.arrayBuffer());
await import('node:fs/promises').then(fs => fs.writeFile('shot.webp', buffer));
See the ScreenshotNeo API documentation for request options such as viewport and resizing, custom CSS and JavaScript, selector captures, waits, blocked resources, headers, cookies, geolocation, caching, asynchronous jobs and bulk capture. Every plan includes every feature: 1,000 shots per month are free with no card; paid plans start at $5 for 3,000 shots, and yearly billing gives two months free. Create a free ScreenshotNeo account to try it.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsFAQ
Does scale: 'css' change browser zoom?
No. It changes the output bitmap’s pixel grid after the page is rendered; browser zoom and viewport settings remain separate.
Best Value
- 【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.
Can I use scale with PDF output?
Playwright’s scale option applies to Page and Locator screenshot images. PDF generation uses PDF-specific paper, margin and scaling settings instead.
Which scale should a shared snapshot baseline use?
Pick one convention, set it explicitly on every assertion and capture helper, and keep the viewport and device scale factor fixed for the project.
Frequently Asked Questions
Does scale: 'css' change browser zoom?
No. It changes the output bitmap’s pixel grid after the page is rendered; browser zoom and viewport settings remain separate.
Can I use scale with PDF output?
Playwright’s scale option applies to Page and Locator screenshot images. PDF generation uses PDF-specific paper, margin and scaling settings instead.
Which scale should a shared snapshot baseline use?
Pick one convention, set it explicitly on every assertion and capture helper, and keep the viewport and device scale factor fixed for the project.
Quick Recap
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.




