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

Use html2canvas when code running in the page should turn a DOM element into a downloadable PNG. Use Playwright or Puppeteer when a server must capture the browser’s actual rendered output, including a full page or a selected element. Browser extensions should use their native tab-capture APIs.

The distinction matters: html2canvas rebuilds an image from DOM and style information; it does not photograph the browser’s rendered pixels. That makes it convenient, but unsupported CSS, cross-origin resources, iframes and very large canvases can change or prevent the result.

Choose the capture method first

Your execution environment and fidelity requirement determine the right JavaScript approach. This table puts a service option first, followed by code you run yourself.

Option Best for Important limitation or reason
ScreenshotNeo (#1 service/API) Production captures without maintaining a browser Removes consent banners, popups and chat widgets before capture; only clean shots are billed, and the lowest paid plan is $5.
html2canvas An element in the current page from client-side JavaScript Returns a canvas reconstructed from DOM and CSS; fidelity depends on supported properties and resource access.
Playwright Server-side full-page or element screenshots Controls a real browser, so it is suitable when rendered output matters; you must run a browser process.
Puppeteer Server-side browser automation and screenshots Also controls a real browser and exposes page screenshot APIs; browser setup is required.
Native extension screenshot API A browser extension capturing a tab Use the browser’s capture API rather than a canvas library; native APIs are more reliable for extensions and avoid canvas-size limits.

Convert an element in the current page with html2canvas

Install and load the library

For a bundled application, install the package with your package manager:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

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.
npm install html2canvas

Then import it in your browser-side module. A script-tag setup can load the project’s browser build instead. The important requirement is that this code executes where window, document and computed styles exist.

Minimal PNG download

Give the area you want to capture an identifier, wait until its content is visible, and call the Promise-based API:

import html2canvas from 'html2canvas';

const element = document.querySelector('#capture');
if (!element) {
  throw new Error('Missing #capture element');
}

const canvas = await html2canvas(element);
const link = document.createElement('a');
link.download = 'webpage.png';
link.href = canvas.toDataURL('image/png');
link.click();

html2canvas(element) resolves to a canvas. toDataURL('image/png') encodes that canvas as a PNG data URL, and the temporary anchor starts the download. This is a representation assembled from the page’s DOM information, not an actual screenshot of browser pixels.

Crop, scale and control the capture

Use html2canvas options when the whole element is not the desired output. The project examples support crop coordinates and an explicit scale. A higher scale can make text sharper, but it also increases memory use and the final file size.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const element = document.querySelector('#capture');
const canvas = await html2canvas(element, {
  x: 0,
  y: 0,
  width: element.scrollWidth,
  height: element.scrollHeight,
  scale: window.devicePixelRatio
});

const link = document.createElement('a');
link.download = 'capture@2x.png';
link.href = canvas.toDataURL('image/png');
link.click();

Capture after fonts, images and asynchronous data have finished loading. If the element is scrollable, use its full scroll dimensions for the requested region; if the page is extremely large, capture smaller sections instead of assuming one unlimited canvas will work.

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.

Why the image may not match the page

CSS support is selective

html2canvas understands a subset of CSS. Properties it does not implement, unusual effects and browser-specific rendering can produce differences from what you see on screen. Treat it as a convenient DOM renderer, not a pixel-equivalence tool. If exact browser rendering is a requirement, use a real-browser capture with Playwright or Puppeteer.

Cross-origin images and canvas security

Images loaded from another origin can taint the canvas or be omitted under browser content-policy rules. Setting useCORS: true helps only when the image server sends the appropriate CORS response header:

const canvas = await html2canvas(document.querySelector('#capture'), {
  useCORS: true
});

A configured proxy is another documented option, but it must be a server you trust and control carefully. A client-side library cannot bypass browser security policy. Do not disable those protections or assume that adding useCORS grants access to every remote image.

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

Iframes

Same-origin frames can be rendered recursively. A cross-origin frame is inaccessible to page JavaScript, as is a sandboxed frame without allow-same-origin; its contents therefore cannot be reconstructed by html2canvas.

Very large pages

Canvas dimensions have browser- and platform-dependent limits. Oversized captures can be blank or only partly rendered, and there is no universal maximum that applies to every browser. Reduce the region, lower the scale, or capture a sequence of sections when a large page fails.

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.

Capture the rendered page with Playwright

Playwright launches a real browser, loads the URL and uses the browser’s screenshot implementation. This is the server-side choice when CSS fidelity, JavaScript execution, lazy loading or a full scrollable page matters.

Full-page Node.js example

Install Playwright and its browser according to the project’s current setup instructions, then run a script such as:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import { chromium } from 'playwright';

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

await page.goto('https://example.com', { waitUntil: 'networkidle' });
await page.screenshot({ path: 'page.png', fullPage: true });

await browser.close();

fullPage: true extends the image through the page’s full scrollable height. For one component, locate it and screenshot the element instead:

const card = page.locator('#capture');
await card.screenshot({ path: 'card.png' });

Wait for a selector or other application-specific readiness condition when network idle is not enough. For pages that lazy-load images, scroll or trigger the page’s own loading behavior before taking the screenshot.

Capture with Puppeteer

Puppeteer offers the same basic real-browser model. Its screenshot API can save a viewport or full page:

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
import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setViewport({ width: 1440, height: 900 });
await page.goto('https://example.com', { waitUntil: 'networkidle0' });
await page.screenshot({ path: 'page.png', fullPage: true });
await browser.close();

Use a real browser when the target is outside your current page, when cross-origin content must render as the browser sees it, or when a server job needs repeatable capture. Browser automation consumes more startup time and resources than an in-page canvas call, so reuse a browser process for batches rather than launching one for every URL.

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

Browser-extension captures

If the code runs in a browser extension and the goal is a visible tab, use the extension’s native screenshot API (for example, the documented captureVisibleTab() family) with the permissions and browser rules for that extension. The html2canvas FAQ recommends native APIs for extensions because they are more reliable and are not constrained by canvas-size limits.

Make captures dependable

Before calling the API

  • Wait for web fonts, images and client-rendered data that must appear.
  • Choose a stable viewport and device scale factor for automation.
  • Hide transient UI such as menus or animations when those are not part of the desired image.
  • For html2canvas, verify that remote images provide the CORS headers you need.
  • For large documents, plan a sectioned capture or a real-browser full-page screenshot.

Common failures and fixes

Symptom Likely cause Fix
External images are missing or the export throws a security error Cross-origin content tainted the canvas Serve the images with the required CORS header and use useCORS: true, or use a trusted proxy. Otherwise use Playwright or Puppeteer.
Fonts, shadows or layout differ from the tab Unsupported CSS or DOM reconstruction Switch to a real-browser screenshot for pixel fidelity; simplify unsupported effects only if html2canvas is required.
An iframe is blank The frame is cross-origin or sandboxed without same-origin access Capture the frame from its own origin or use browser automation with appropriate access; page JavaScript cannot read it directly.
The image is blank or truncated The requested canvas exceeds a browser/platform limit Lower scale, reduce the region, or capture several smaller images.
Node.js reports that window or document is undefined html2canvas is client-side only Run it in a browser, or use Playwright/Puppeteer on the server.
The screenshot contains a loading spinner or missing lazy images Capture started before the page was ready Wait for a selector or application state, then capture; in automation, explicitly exercise lazy-loading behavior.

Performance, reliability and output decisions

html2canvas avoids browser-launch overhead and is a good fit for an interactive “download this card” button. Its work and memory usage grow with the captured area and scale. Browser automation is heavier, but it executes the same layout and painting pipeline users see and is easier to centralize in a server workflow. Reuse browser instances for batches, cap concurrency to the resources available, and write files as they complete rather than holding many large buffers in memory.

PNG is lossless and preserves text and flat UI graphics. The example above intentionally exports PNG because that is the documented download pattern. If your product needs another format, check the canvas and browser APIs you support and test quality, transparency and file size on representative pages.

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

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server for developers. One GET request returns a PNG, JPEG, WebP or PDF. Before capture, it accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups and chat widgets; each cleanup step can be disabled. Bot checks/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.

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

Use the API from any language. The complete documentation is at https://screenshotneo.com/docs/.

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

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)
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}`);

Controls available when code grows beyond one URL

ScreenshotNeo supports full-page capture with lazy images loaded; a single element by CSS selector; dark mode; 12 device presets or any viewport; retina scale; PDF paper size, margins, landscape and page ranges; HTML/CSS-to-image; custom CSS and JavaScript; clicking an element before capture; hidden selectors; waits for a selector, delay or network idle; blocking ads, trackers, requests or resource types; custom headers, cookies, user agent and Authorization; timezone and geolocation; transparent backgrounds; image resizing; caching with a chosen TTL; signed links for public <img> tags; asynchronous jobs with signed webhooks; bulk capture of up to 100 URLs per call; a usage API; an OpenAPI specification; and compatibility with parameter names used by other screenshot APIs.

An MCP server exposes take_screenshot, get_page_info and capture_pdf to Claude, Cursor and other MCP clients, so an AI agent can request captures without your application managing browser automation.

Plan Allowance and price
Free 1,000 shots/month, no card
Starter $5 for 3,000 shots
Growth $15 for 15,000 shots
Pro $39 for 60,000 shots
Scale $99 for 250,000 shots
Business $249 for 1,000,000 shots

Yearly billing provides two months free, and every feature is included on every plan. Create a free ScreenshotNeo account to get 1,000 screenshots a month with no card; paid plans start at $5 for 3,000.

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

Frequently Asked Questions

Does html2canvas send my page to a remote service?

The library runs in the browser context where you call it. Your own application decides whether to upload the resulting canvas or keep the generated image locally.

Can I use both approaches in one product?

Yes. A client-side html2canvas preview can provide an immediate download for simple elements, while a server-side Playwright job handles pages that require full browser fidelity or cross-origin rendering.

What do ScreenshotNeo’s X-Page-Verdict and X-Billed headers tell me?

They identify how the response was classified and whether it counted as a billed clean screenshot, including non-billed outcomes such as failed loads or cache hits.

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.

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