For a regular Playwright screenshot, set type to 'png', 'jpeg' or 'webp'. PNG is the default. You can also let the filename extension choose the format by supplying a path such as 'screenshot.webp'. Use JPEG or WebP when lossy compression is acceptable; use PNG or lossless WebP when preserving image detail matters. If you are creating a Playwright Test visual snapshot, that is a separate API: snapshots default to PNG, and a name ending in .webp selects WebP.
Set the format for a regular screenshot
Both page and locator screenshots accept the type option. The supported values are 'png', 'jpeg' and 'webp'; when you do not specify a type or a path that selects one, the regular screenshot API defaults to PNG.
Here is a page screenshot with an explicit type and a matching filename:
await page.screenshot({
path: 'screenshot.webp',
type: 'webp'
});
The API calls the JPEG type 'jpeg'. The filename can end in either .jpg or .jpeg. For example:
#1 Best Overall
await page.screenshot({
path: 'screenshot.jpeg',
type: 'jpeg'
});
A path can also select the format from its extension, so this saves a WebP image without an explicit type:
await page.screenshot({ path: 'screenshot.webp' });
For clarity, keep the extension and explicit type aligned. That makes the intended output apparent to a person or a later script reading the file. If you need deterministic behavior in code, set type explicitly rather than relying on a reader to infer your intention from the name.
Save the result to a file
Supply path when you want Playwright to write the screenshot to disk. The following example assumes that page is an open Playwright page and its navigation or setup is already complete:
await page.goto('https://example.com');
await page.screenshot({
path: 'page-shot.webp',
type: 'webp',
quality: 85
});
The number in this example is a chosen setting, not a Playwright-recommended quality level. WebP supports quality; the documented default is 100, which Playwright describes as lossless. A lower value produces lossy output. Choose and test a value that suits your own images and use case rather than assuming a particular setting will produce a specific file size or visual result.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Return image data instead of writing a file
Omit path when you want the screenshot as a buffer—for example, to pass it to another tool or process it in memory. You can still select the format:
Rank #2
const image = await page.screenshot({
type: 'webp',
quality: 85
});
// `image` is the screenshot buffer; pass it to your own storage
// or image-processing code.
This avoids choosing a disk filename as part of capture. If your next step requires a file, write the buffer using your application’s normal file-handling code and use a filename whose extension matches the selected type.
Choose PNG, JPEG or WebP
Format selection is a trade-off between image fidelity, compression and transparency. Playwright documents the available behavior and defaults, but does not provide comparative file-size measurements. A format choice alone therefore does not establish how much smaller a particular screenshot will be.
| Format | Quality option | Transparency | Useful when |
|---|---|---|---|
| PNG | quality does not apply. PNG is the default for regular screenshots. |
Can be used with omitBackground: true. |
You want the default format or need to preserve image detail without using lossy JPEG or lower-quality WebP. |
| JPEG | Supported; documented default is 80. | omitBackground does not apply. |
Lossy compression is acceptable and you do not need a transparent background. |
| WebP | Supported; documented default is 100, described by Playwright as lossless. Lower values are lossy. | Can be used with omitBackground: true. |
You want WebP output and need to choose between the documented lossless default and a lossy quality setting. |
Use the quality option only for JPEG or WebP. It has no effect on PNG. The documented defaults describe the API settings, not a guarantee that a given image will look identical across formats, browsers or systems.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesWhen the background must be transparent
Set omitBackground: true if you need Playwright to omit the page background in a format that supports transparency:
await page.screenshot({
path: 'transparent-shot.png',
type: 'png',
omitBackground: true
});
This option is not applicable to JPEG. Do not choose JPEG if a transparent result is a requirement; use a format that supports transparency instead.
Use a locator screenshot for a single element
A locator screenshot uses the same format options as a page screenshot. Use it when the output should capture one element rather than the full page:
const card = page.locator('.product-card');
await card.screenshot({
path: 'product-card.webp',
type: 'webp',
quality: 90
});
Choose the locator and its format independently of the larger page capture. The format still describes the encoded image: PNG ignores quality, while JPEG and WebP accept it. Keep a transparent-background requirement in mind when choosing the type.
Free tools Windows power users keep installed
One-click scans. No signup required.
Do not confuse screenshots with visual-test snapshots
page.screenshot() and locator.screenshot() create ordinary screenshots. Playwright Test’s expect(page).toHaveScreenshot() is an assertion that captures and compares a visual snapshot. Its format selection is not interchangeable with the regular screenshot options.
Visual snapshots are stored as PNG by default. To use WebP, give the snapshot a name ending in .webp:
await expect(page).toHaveScreenshot('home-page.webp');
The documented screenshot assertion name extensions are .png and .webp. Do not assume that the regular screenshot API’s JPEG option is available for toHaveScreenshot(). For visual comparisons, PNG or WebP can be used for lossless snapshots according to the assertion documentation; JPEG or lower-quality WebP in ordinary screenshot calls can be lossy.
Rank #4
Switching snapshot formats does not solve unrelated differences in rendered output. A format change is not a substitute for generating and comparing baselines in a consistent browser environment.
Make visual captures repeatable
A screenshot is a rendering produced by a particular browser and environment, not just an image-format setting. Playwright’s visual comparison guidance identifies the host operating system, browser version, settings, hardware, power source and headless mode as factors that can affect browser rendering. For repeatable comparisons, generate the baseline and subsequent screenshots in the same environment.
- Keep the environment used to create visual baselines consistent with the environment used for later comparisons.
- Record the selected screenshot type and any lossy
qualityvalue alongside your capture configuration. - Do not interpret a changed image as a format problem until you have considered the browser and host differences.
The title does not identify a Playwright package version, language binding or browser engine. Confirm the API supported by your installed version if its local reference differs from the behavior described here.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Common format problems and fixes
The file is PNG even though the output name was unexpected
A regular screenshot defaults to PNG unless a supported type is selected or the path extension selects another format. Set type explicitly and check the actual path being passed to the screenshot call. Keep the extension and type consistent so your application does not label an image as one format when it contains another.
The code uses jpg as the type
Use type: 'jpeg'; 'jpeg' is the API value. The output filename may use .jpg or .jpeg.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Changing quality has no effect on PNG
That is expected: quality does not apply to PNG. Use JPEG or WebP if you need to set that option, and remember that JPEG and lower-quality WebP are lossy.
The screenshot does not have a transparent background
Check that the screenshot uses omitBackground: true and that the chosen format supports transparency. JPEG does not support this option.
A visual snapshot call rejects or ignores a JPEG choice
Check which API is being called. toHaveScreenshot() is a visual-test assertion with documented .png and .webp snapshot names; the regular screenshot API’s JPEG setting is not a documented assertion option.
Visual comparisons change after a format adjustment
Check whether the change is in the regular screenshot encoding or in the Playwright Test snapshot setup. Then compare the environment used for the capture: browser version, host OS, settings and headless mode can affect rendering independently of format. Keep the baseline and comparison run in the same environment before treating a rendering difference as an encoding issue.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Or skip the browser setup
If you need an image from a URL without setting up a Playwright browser capture, ScreenshotNeo accepts a URL in a single GET request and can return PNG, JPEG, WebP or PDF. See the ScreenshotNeo API documentation for request options and response details.
curl -G "https://api.screenshotneo.com/v1/shot"
-d access_key=YOUR_API_KEY
--data-urlencode url=https://stripe.com
-o shot.webp
ScreenshotNeo accepts cookie or consent banners before capture and removes more than 60 known consent platforms, newsletter popups and chat widgets; each of those steps can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and the response identifies the page verdict and billing status in headers. An MCP server provides take_screenshot, get_page_info and capture_pdf tools for Claude, Cursor and other MCP clients. The Free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 screenshots.
Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.
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.




