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

To turn a website into an image, capture its rendered output with a browser automation tool such as Playwright. Use a viewport screenshot for what is currently visible, a full-page screenshot for the entire scrollable page, or an element screenshot for one component. For client-side image generation from DOM and CSS, html2canvas is an alternative—but it reconstructs the image and may not match the browser’s actual pixels.

Choose how to generate the image

Approach What it produces Use it when Main limitation
Playwright browser screenshot Pixels captured from a page rendered in a browser; can capture the viewport, full page, or an element You need a website screenshot that reflects browser rendering Results can vary with the browser and capture environment
html2canvas A canvas image reconstructed from DOM nodes and styles You need in-browser DOM-to-image output and reconstruction is acceptable It is not a native screenshot; CSS support and cross-origin resource access can limit fidelity

Playwright can save a screenshot to a file or return screenshot bytes for further processing. Its official screenshot guide covers page and element captures, while the Page API documents options including full-page capture and transparent backgrounds. See the Playwright screenshot guide.

Capture a website with Playwright

The following JavaScript example uses Playwright’s Page screenshot API. Install Playwright in your project and install its browser before running the script. Save this as an ES module, for example capture.mjs, then run it with Node.js.

import { chromium } from 'playwright';

const browser = await chromium.launch();
const page = await browser.newPage({
  viewport: { width: 1440, height: 900 },
});

try {
  await page.goto('https://example.com', { waitUntil: 'load' });
  await page.screenshot({ path: 'website.png' });
} finally {
  await browser.close();
}

Change the viewport dimensions to control the responsive layout. Set the viewport before navigation when you want the page to render at a particular size; resizing can change the page layout. The output format follows the file extension in the path. For a JPEG output, use a filename such as website.jpg; JPEG does not support transparency.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • 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.

Capture the full scrollable page

Set fullPage: true to capture beyond the current viewport:

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

A full-page capture represents the scrollable page as if displayed on a very tall screen. It is useful for a long article or landing page, but the resulting image may be much taller than a typical screen. If you need a particular section rather than the whole page, capture an element instead.

Capture one element

Use a locator’s screenshot method to capture a particular component, such as a card, chart, or article body:

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 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.
const card = page.locator('.product-card').first();
await card.screenshot({ path: 'product-card.png' });

Replace .product-card with a selector that identifies the element on your page. If the selector matches multiple elements, choose the intended one explicitly, for example with .first(), or use a selector that uniquely identifies it. The element must be available on the page when the screenshot call runs.

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

Return image bytes instead of writing a file

Omit the path option to receive screenshot data as bytes. You can pass that buffer to another part of your application or write it yourself:

const imageBytes = await page.screenshot({ type: 'png' });
// Pass imageBytes to an image-processing step, or save it with your application.

Use the type option to select PNG or JPEG when working with bytes. A transparent background is available for supported output formats; it does not apply to JPEG. Check the current Page API reference for the exact options supported by the version installed in your project.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • 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.

Render HTML with html2canvas

html2canvas runs in the browser and builds a canvas image from the page’s DOM and applied styles. It does not capture the browser’s rendered pixels. The project describes the result as potentially not fully accurate to the real representation because it is reconstructed from information available on the page. CSS support depends on properties implemented by the project, and the library is browser-dependent rather than suitable for Node.js. Read its documentation before relying on a specific style or browser behavior.

For a simple client-side capture, load the library in a page and call it with the element to render:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const element = document.querySelector('#capture-area');

if (!element) {
  throw new Error('Could not find #capture-area');
}

const canvas = await html2canvas(element);
const imageUrl = canvas.toDataURL('image/png');

const link = document.createElement('a');
link.href = imageUrl;
link.download = 'capture.png';
link.click();

Include html2canvas in the page using the installation method appropriate to your project, then run this code in the browser after the target element exists. The returned canvas can be used directly in browser code or converted to a data URL as shown. This approach is appropriate when client-side reconstruction meets your needs; check the output on the actual page before treating it as a faithful screenshot.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • 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

Cross-origin images and other resources

html2canvas does not bypass browser content-policy restrictions. Cross-origin assets can therefore be absent from the resulting canvas unless they are served in a way that permits access. The project documentation describes using a proxy that returns a base64 data URI as one possible way to make resources usable. Confirm that you are allowed to retrieve and process the resources, and test the specific assets involved.

Make screenshot results repeatable

For visual regression testing, Playwright Test can create screenshot baselines on an initial run and compare later screenshots against them. Keep the capture environment consistent: the project documentation notes that output can vary with operating system, browser version, settings, hardware, power source, and headless mode. Dynamic content can also make otherwise unchanged pages differ, so consider suppressing or controlling it when deterministic comparisons matter. See Playwright visual comparisons.

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

Troubleshoot common problems

  • The screenshot has the wrong responsive layout: Set the intended viewport before navigating. A different viewport can trigger different page styles and layout.
  • The full-page image is unexpectedly tall: fullPage: true captures the entire scrollable page, not just the visible screen. Use a viewport capture or an element capture if that is not what you need.
  • The element capture fails or targets the wrong content: Check that the selector matches the intended element and that it exists before calling the screenshot method. Narrow the selector or choose a specific match.
  • The saved file is not the format you expected: For path-based Playwright screenshots, use a filename extension matching the intended format. For screenshots returned as bytes, set the supported type option.
  • html2canvas output differs from the page: This is a reconstruction from DOM and styles, not a browser screenshot. Check whether the styles and resources on that page are supported, or use Playwright when actual browser-rendered output is required.
  • Images are missing from html2canvas output: Check whether they are cross-origin. Browser content policies still apply; configure permitted access or a suitable proxy if appropriate.
  • Visual regression comparisons change between runs: Compare screenshots in a consistent browser and host environment, and control dynamic page content where possible.

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server. A single request can return an image or PDF, without installing and managing a local browser for the capture. Cookie and consent banners are accepted like a visitor and removed along with supported newsletter popups and chat widgets before capture; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify page verdict and billing status in headers. Its MCP server provides screenshot tools for AI agents, including Claude, Cursor, and other MCP clients. The free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots. See the ScreenshotNeo documentation.

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.

For example, this cURL request saves a WebP screenshot of a page:

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 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.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

Get an API key by signing up for ScreenshotNeo free.

Frequently asked questions

Can I use html2canvas in a Node.js script?

The html2canvas project describes itself as browser-dependent and unsuitable for Node.js. For a Node.js workflow that needs browser-rendered output, use browser automation such as Playwright.

Does html2canvas take a real screenshot?

No. It reconstructs an image from DOM and style information rather than capturing the browser’s rendered pixels.

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

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.