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

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Use Playwright to open a browser, navigate to the URL with page.goto(), then save the result with page.screenshot(). By default, the screenshot shows the current viewport. Set fullPage: true to capture the full scrollable page instead.

Capture a screenshot of a URL with Playwright

Install Playwright and its Chromium browser, then run this JavaScript example. The capture itself is two steps: navigate to the address and call the page’s screenshot method.

  1. In a new project, install Playwright and Chromium:

    npm install playwright
    npx playwright install chromium
  2. Save this as screenshot.js, replacing the example address with the page you want to capture:

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
    const { chromium } = require('playwright');
    
    (async () => {
      const browser = await chromium.launch();
      try {
        const page = await browser.newPage();
        await page.goto('https://example.com');
        await page.screenshot({ path: 'screenshot.png' });
      } finally {
        await browser.close();
      }
    })();
  3. Run it with node screenshot.js. The image is saved as screenshot.png in the current directory.

    #1 Best Overall
    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

The example uses Chromium, which you can swap for another supported browser. Playwright’s Page API documents the same launch, page creation, navigation, and screenshot sequence using WebKit. Consult the live API documentation for option availability in the Playwright version you use.

Choose what to capture

Viewport or full page

Without extra options, page.screenshot() captures the visible viewport. For the entire scrollable document, use:

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

The Playwright Page API describes fullPage as capturing the full scrollable page instead of the currently visible viewport. Very long pages can produce large images; use a viewport capture, a region, or an element capture if you only need part of the page.

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

Capture a region or one element

Use clip to capture a rectangle in page coordinates:

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: 'region.png',
  clip: { x: 0, y: 0, width: 800, height: 400 }
});

To capture a particular element, take the screenshot from a locator instead of the page:

await page.locator('.header').screenshot({ path: 'header.png' });

Replace .header with a CSS selector matching the element you want. If the selector does not identify an element, or the element is not ready to be captured, adjust the selector or wait for the page state your capture requires.

Save to a file or keep the image bytes

Passing path saves the screenshot to a file. If you omit it, the method returns image bytes in a buffer, which you can pass to another function or tool:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const imageBuffer = await page.screenshot();

Format and image quality

Playwright infers the image format from the file extension; its API documents PNG, JPEG, and WebP. JPEG quality is configurable, while the quality option does not apply to PNG. For example, to save a JPEG with a chosen quality value:

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.
await page.screenshot({ path: 'screenshot.jpg', type: 'jpeg', quality: 80 });

Check the Page API for supported options and limits for your installed version. Format and quality involve a trade-off between image appearance and file size; there is no universally best setting.

Pixel scale

The scale option controls the relationship between CSS pixels and screenshot pixels. scale: 'css' produces one image pixel per CSS pixel; scale: 'device' uses device pixels and can create a larger image on high-density displays. The documented API default is device.

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

Make captures useful and repeatable

A screenshot records the rendered page state at capture time. If a page has dynamic content, decide what state you need before capturing—for example, whether an animation, rotating banner, or late-loading content should be present. Use an appropriate wait or page-state condition for your application rather than assuming navigation alone means every visual element has settled.

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

For a one-off image, call page.screenshot(). For visual regression checks with Playwright Test, use expect(page).toHaveScreenshot(). The test runner creates a reference on the first execution and compares later output against it. Screenshot assertions wait for two consecutive screenshots to match before comparing to the expectation, and require the Playwright test runner.

Comparisons can vary across host operating systems, browser versions, settings, hardware, power source, and headless mode. Playwright’s visual comparison documentation advises keeping environments consistent when reliable comparisons matter. The guide is under /docs/next and may describe unreleased behavior; use the stable Page API as the primary reference for screenshot options.

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

Or skip the browser setup

ScreenshotNeo is a screenshot API and MCP server for developers. It accepts one GET request with a URL and returns an image or PDF; its capture options and API details are in the ScreenshotNeo documentation.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

ScreenshotNeo removes cookie/consent banners, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Learn about ScreenshotNeo or sign up free for 1,000 screenshots a month with no card.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting

The browser does not launch

Playwright’s package and browser binaries are separate. If launch reports that Chromium is missing, run npx playwright install chromium for the installed Playwright package, then rerun the script.

The screenshot is only a small portion of the page

The default is the viewport. Add fullPage: true if you need the full scrollable document, or use a locator screenshot or clip if you need a specific element or rectangle.

The screenshot is blank or misses content

Check that the URL is correct and navigation completed successfully. If content appears after navigation, wait for the relevant element or state before capturing. A page’s scripts, network behavior, or access checks may also prevent the expected content from rendering.

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.

The output is unexpectedly large or looks different

Use scale: 'css' if you want one image pixel per CSS pixel. For smaller output, select only the needed region or element, or choose a suitable JPEG quality where lossy compression is acceptable. For regression tests, compare in a consistent browser and host environment.

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

Frequently asked questions

Can I use this with a URL supplied at runtime?

Yes. Replace the literal address passed to page.goto() with a validated variable containing the URL. If URLs come from users, apply your application’s own validation and access controls before navigating.

Does fullPage: true scroll the browser for a series of screenshots?

No. It requests a single screenshot of the full scrollable page. For a sequence of separate viewport captures, implement that workflow explicitly rather than treating one full-page image as multiple shots.

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.