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

For a browser-only screenshot of a DOM element, call html2canvas(element), wait for the returned canvas, then export it with toBlob() or toDataURL(). This is a reconstructed rendering, not a pixel-perfect browser screenshot. For exact CSS, server-side jobs, full-page captures, or URL-based automation, use Playwright or a hosted screenshot API instead.

Choose the right HTML-to-image method

Your choice depends on where the code runs and how faithfully the result must match the browser.

Method Runs in Best for Main limitation
html2canvas A page in the browser Quick exports of an element you already display Reconstructs supported DOM and CSS; unsupported properties and cross-origin content can fail
html-to-image Browser JavaScript Convenient PNG, JPEG, Blob, pixel-data, or SVG helpers Uses SVG foreignObject; browser support and cross-origin assets still need testing
Playwright Node.js, CI, or another server process Real-browser rendering, URL navigation, full-page screenshots, and high CSS fidelity You operate a browser runtime and its resources
ScreenshotNeo Hosted API or MCP client URL screenshots without maintaining browser infrastructure Your page must be reachable by the service, and provider-specific limits and privacy terms apply

ScreenshotNeo is the first hosted screenshot API to try when you want clean captures: it removes consent banners, popups, and chat widgets before capture, bills only clean shots, and its paid plan starts at $5 for 3,000 shots. See ScreenshotNeo for access and documentation.

Convert an element with html2canvas

Install and select the element

Install the package in an application that runs in a browser:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
npm install @html2canvas/html2canvas

Give the target a stable selector. The element must be present and laid out before capture.

#1 Best Overall
Sale
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
<section id="invoice">
  <h1>Invoice 1042</h1>
  <p>Due 30 September</p>
</section>
<button id="download">Download PNG</button>

Capture and download a PNG

This complete example waits for the canvas, uses the device pixel ratio for sharper output, and sizes the virtual window to the element’s scroll dimensions.

import html2canvas from '@html2canvas/html2canvas';

const element = document.querySelector('#invoice');
if (!element) throw new Error('Invoice element was not found');

const canvas = await html2canvas(element, {
  backgroundColor: '#ffffff',
  scale: window.devicePixelRatio,
  useCORS: true,
  windowWidth: element.scrollWidth,
  windowHeight: element.scrollHeight
});

canvas.toBlob((blob) => {
  if (!blob) throw new Error('Image encoding failed');
  const url = URL.createObjectURL(blob);
  const link = document.createElement('a');
  link.href = url;
  link.download = 'invoice.png';
  link.click();
  URL.revokeObjectURL(url);
}, 'image/png');

The library reads the DOM and computed styles, paints the supported representation to a canvas, and resolves the promise with that canvas. It does not capture the browser’s already-rasterized pixels, so visual differences are expected for unsupported CSS.

Control dimensions, scale, and page state

Capture all content in a scrolling node

An element with a fixed viewport can otherwise produce a clipped image. Passing windowWidth: element.scrollWidth and windowHeight: element.scrollHeight gives html2canvas the complete layout dimensions. Set an explicit scale; device-pixel-ratio is a useful default, while a lower value reduces memory use.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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

Wait for dynamic content

Start the capture only after application data, images, and web fonts have loaded. For an image, await its decode() promise where available; for application data, wait for the render state your framework exposes. A timeout alone can still capture a blank chart or a fallback font, so test the actual readiness condition.

Hide controls or transient UI

Use a capture-specific CSS class or temporarily hide buttons and loading indicators before calling html2canvas, then restore them after the promise resolves. Keep the DOM in its final visual state; the library cannot include pixels that have not been rendered.

Export the canvas as an image

Use toBlob for downloads and uploads

toBlob() encodes asynchronously and lets you create an object URL without placing the entire encoded image in a JavaScript string. Revoke the URL after the download lifecycle finishes. This is the preferred approach for large images.

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.
canvas.toBlob((blob) => {
  if (!blob) return;
  const objectUrl = URL.createObjectURL(blob);
  const anchor = document.createElement('a');
  anchor.href = objectUrl;
  anchor.download = 'capture.png';
  document.body.appendChild(anchor);
  anchor.click();
  anchor.remove();
  URL.revokeObjectURL(objectUrl);
}, 'image/png');

Use toDataURL when an inline string is required

const canvas = await html2canvas(document.querySelector('#capture'));
const dataUrl = canvas.toDataURL('image/png');

toDataURL() returns a data URL and falls back to PNG if the requested type is unsupported. The encoded bytes are held in an in-memory string, so a large canvas can consume substantially more memory than a Blob.

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

Handle cross-origin images and tainted canvases

Canvas security prevents JavaScript from reading pixels when an image was fetched without appropriate cross-origin permission. Calling toBlob() or toDataURL() after that happens can throw a SecurityError.

  • Configure the image server to send an Access-Control-Allow-Origin response that permits your page.
  • Set crossorigin="anonymous" on the image before assigning its src.
  • Pass useCORS: true to html2canvas.
  • If you control neither origin, proxy the asset through your own origin and add the required response headers.
const image = new Image();
image.crossOrigin = 'anonymous';
image.src = 'https://cdn.example.com/logo.png';
await image.decode();

A cross-origin iframe is a separate case: html2canvas cannot read the iframe’s document. Capture content inside that frame at its own origin, or use a browser-level screenshot workflow where the required access is available.

Rank #4
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

When html-to-image is a better browser library

The html-to-image package provides toPng, toJpeg, toBlob, toPixelData, and toSvg. Its documented approach clones the node, serializes it into an SVG foreignObject, and can then paint that SVG to an off-screen canvas. This can preserve more browser CSS behavior than a hand-written DOM traversal. SVG foreignObject support and cross-origin fonts or images still vary by browser, so verify the exact browsers your users run.

Use Playwright for real-browser screenshots

Playwright launches a browser, navigates to a URL, executes the page normally, and exposes screenshot clipping and output options. It is the practical choice for Node.js or CI jobs that need full-page output or CSS fidelity.

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.
import { chromium } from 'playwright';

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

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

For an element-only image, locate the element and use its screenshot method. For a dynamic application, wait for a selector or an application-specific ready state rather than assuming that networkidle means every chart and font is complete. Browser automation also gives you control over authentication, headers, cookies, viewport, and JavaScript, but you must provision and update the browser runtime.

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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Hosted HTML-to-image APIs

A hosted service is useful when your process should send a URL or markup and receive an image without running Chromium yourself. Check each provider’s service limits, data retention, privacy terms, authentication model, and supported output formats before sending private pages.

ScreenshotNeo: clean URL captures and an MCP server

ScreenshotNeo accepts one GET request at https://api.screenshotneo.com/v1/shot and returns PNG, JPEG, WebP, or PDF. Before capture it can accept the cookie or consent banner like a visitor and remove more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and the response identifies the result with X-Page-Verdict and X-Billed headers.

It also provides an MCP server for Claude, Cursor, and other MCP clients, with take_screenshot, get_page_info, and capture_pdf tools. Other capabilities include full-page capture with lazy images loaded, CSS-selector element capture, dark mode, 12 device presets plus custom viewports, retina scale, PDF paper size/margins/landscape/page ranges, HTML/CSS-to-image, custom JavaScript and CSS, pre-capture clicks, hidden selectors, waits for a selector, delay, or network idle, ad/tracker/request/resource blocking, custom headers/cookies/user agent/Authorization, timezone and geolocation, transparent backgrounds, resizing, selectable cache TTL, signed public-image links, asynchronous jobs with signed webhooks, bulk capture of 100 URLs per call, a usage API, an OpenAPI specification, and compatibility with parameter names used by other screenshot APIs.

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

One-call examples

See the ScreenshotNeo API documentation for authentication and all options. The following calls capture Stripe’s home page.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
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)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

Plans and usage

Plan Included shots per month Price
Free 1,000 $0, no card
Starter 3,000 $5
Growth 15,000 $15
Pro 60,000 $39
Scale 250,000 $99
Business 1,000,000 $249

Yearly billing gives two months free, and every feature is included on every plan.

Or skip the browser setup

Use the one-call example above when you do not want to install or operate a browser. Cookie banners, newsletter popups, and chat widgets are removed before the shot; bot checks, blank pages, and failed loads are never billed. The MCP server lets AI agents take screenshots, and the Free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000.

Create a free ScreenshotNeo account to get started.

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

Troubleshoot incomplete or incorrect images

Symptom Likely cause Fix
Blank or partially rendered image Images, fonts, or asynchronous data were not ready Await image decoding and application readiness; capture after the final render; set window dimensions to the element’s scroll dimensions
SecurityError or “tainted canvas” An image was fetched without CORS approval Send Access-Control-Allow-Origin, set crossorigin="anonymous" before src, enable useCORS, or proxy the asset
CSS does not match the page html2canvas supports only the CSS properties it understands Try html-to-image after browser testing, or switch to Playwright for a real-browser capture
Cross-origin iframe is empty The browser’s same-origin policy blocks iframe document access Capture within the iframe’s origin or use a browser-level workflow with appropriate access
Browser tab becomes slow or crashes A large canvas, high scale, or data URL consumes too much memory Lower scale, capture smaller regions, use toBlob(), and revoke object URLs
Server capture misses lazy images The page has not loaded content below the initial viewport Use Playwright to scroll or wait for the images, or use ScreenshotNeo full-page capture with lazy images loaded

Performance, reliability, and privacy decisions

  • Rendering fidelity: html2canvas and html-to-image are convenient in-page reconstructions. Playwright renders what a browser renders, which is preferable for complex CSS, web fonts, and browser-native behavior.
  • Execution location: Browser libraries keep HTML in the user’s browser. Playwright and hosted APIs move work to a server or service, so review where sensitive markup and assets are processed.
  • Authentication: In-page code already sees the logged-in document. Playwright can set browser context state; ScreenshotNeo supports custom headers, cookies, user agents, and Authorization values.
  • Output and clipping: Canvas libraries produce image data from a node. Playwright supports full-page and clipped screenshots. ScreenshotNeo supports element selectors, full pages, PNG/JPEG/WebP, and PDF.
  • Operational cost: A browser library has no capture-service bill but consumes the user’s memory and CPU. Playwright adds browser maintenance. ScreenshotNeo charges only clean shots, identifies billing status in response headers, and offers a no-card free tier.

A practical decision checklist

  1. Choose html2canvas when the target is already in a browser page and approximate CSS rendering is acceptable.
  2. Choose html-to-image when its SVG-based serialization matches your browser matrix and you want its format helpers.
  3. Choose Playwright when you need a real browser, server-side or CI execution, authenticated navigation, full-page output, or higher CSS fidelity.
  4. Choose ScreenshotNeo when you want URL capture without browser operations, need cleanup of consent UI, require PDF or bulk jobs, or want AI agents to call screenshot tools through 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.