Use Playwright’s page.screenshot() method to save a website screenshot from Node.js. Install Playwright and its browser, navigate to the page, await the screenshot, then close the browser. By default, the method captures the current viewport; set fullPage: true for the full scrollable page or call screenshot() on a locator to capture one element.
Install Playwright and a browser
For this example, use the Playwright package with WebKit. Install it in a Node.js project, then install the browser binary:
npm install playwright
npx playwright install webkit
Playwright can also launch Chromium or Firefox. Install the browser you choose with the corresponding Playwright install command, then change the import and launch call in the script.
Take a website screenshot with Node.js
Save this as screenshot.js. Replace the URL with the page you want to capture.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
const { webkit } = require('playwright');
(async () => {
const browser = await webkit.launch();
try {
const context = await browser.newContext();
const page = await context.newPage();
await page.goto('https://example.com');
await page.screenshot({ path: 'screenshot.png' });
} finally {
await browser.close();
}
})();
Run it with node screenshot.js. The browser opens, loads the URL, writes screenshot.png in the current directory, and closes. The await before page.screenshot() ensures the capture finishes before the script proceeds. The finally block closes the browser even if navigation or capture fails.
This uses the CommonJS require syntax. In an ES module project, import WebKit with import { webkit } from 'playwright'; and otherwise keep the same workflow.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Choose what to capture
Current viewport
The default captures the visible browser viewport:
await page.screenshot({ path: 'screenshot.png' });
Full scrollable page
Set fullPage: true to capture the full scrollable page as one tall image:
await page.screenshot({ path: 'screenshot.png', fullPage: true });
One element
Use a locator to capture an element, such as a header matching the .header CSS selector:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
await page.locator('.header').screenshot({ path: 'header.png' });
The output is clipped to that element’s position and size. Locator-based screenshots are preferable to the discouraged ElementHandle screenshot method in new code.
A rectangular region
Use the page screenshot’s clip option when you need a specific rectangle rather than a whole page or element. Its coordinates and dimensions are x, y, width, and height:
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
await page.screenshot({
path: 'region.png',
clip: { x: 20, y: 30, width: 640, height: 400 }
});
These coordinates describe the region to capture in the page screenshot; choose dimensions that fit the content you need.
Save an image or use the returned Buffer
Providing path writes the image to a file. If you omit it, page.screenshot() returns a Buffer that you can pass to another library or process in memory:
Free tools Windows power users keep installed
One-click scans. No signup required.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
const image = await page.screenshot();
PNG is the default. Playwright also supports JPEG and WebP; the output format can be inferred from the filename extension. JPEG quality is configurable, while quality does not apply to PNG. The documented options also include omitBackground: true for transparency, which does not apply to JPEG.
Make captures more consistent
For captures that will be reviewed or compared, control visual changes that are irrelevant to the test:
animations: 'disabled'disables CSS animations and transitions for the screenshot. Playwright documents how finite and infinite animations are handled.caret: 'hide'hides the text caret; this is the default.scale: 'css'produces one output pixel per CSS pixel and can keep high-DPI captures smaller.scale: 'device'uses device pixels and is the documented default.maskandmaskColorcover selected locator content in the screenshot.styleapplies CSS while taking the screenshot, for example to hide changing elements.
These options can reduce unwanted variation, but they do not guarantee identical rendering across machines. Browser version, operating system, settings, hardware, power source, and headless mode can affect visual output. Keep the environment consistent when generating and comparing baselines.
Use a visual assertion for regression testing
For a maintained Playwright Test visual check, use await expect(page).toHaveScreenshot() rather than saving a one-off image with page.screenshot(). The assertion waits until two consecutive page screenshots match, then compares the result with the expected image. The first run can create the reference snapshot. Keep the test environment consistent so differences are less likely to come from rendering conditions rather than an actual page change.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesTroubleshooting
- The browser does not launch: Install the browser binary for the engine used in the script, such as
npx playwright install webkitfor WebKit. Make sure the installed browser matches the engine imported and launched. - The output file is missing or incomplete: Await
page.screenshot()and check that the script has permission to write to the chosen path. A relative path is resolved from the directory where Node.js runs. - The screenshot only shows the visible portion: The default is a viewport capture. Set
fullPage: trueto capture the full scrollable page. - An element capture fails or is empty: Check that the locator matches the intended element on the loaded page. Use a CSS selector that identifies the element, such as
.header. - Visual comparison changes between runs: Keep browser and host settings consistent, and consider disabling animations or masking dynamic content. Rendering differences can still occur across environments.
Or skip the browser setup
For a one-request capture instead of managing a local browser, ScreenshotNeo is a website screenshot API and MCP server for developers. One GET request returns an image or PDF:
Quick Recap
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
See the ScreenshotNeo API documentation for request options. Cookie banners and consent prompts, newsletter popups, and chat widgets are removed before the shot; those steps can be turned off. Bot checks and 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 provides screenshot tools for AI agents using Claude, Cursor, or another MCP client. The Free plan includes 1,000 shots a month without a card; paid plans start at $5 for 3,000 shots. Learn about ScreenshotNeo or sign up for 1,000 free screenshots a month, no card required.
References
- Playwright Page API: screenshot
- Playwright screenshots guide
- Playwright visual comparisons
- Playwright screenshots (MCP)
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.

