What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Use html2canvas(element) when the conversion can happen in a browser. It returns a canvas that you can download as PNG, JPEG, or another supported type. This is convenient, but it reconstructs the element from readable DOM styles rather than taking a pixel-for-pixel browser screenshot. Unsupported CSS, cross-origin images, and cross-origin iframes can therefore produce differences or failures.
For a real-browser capture in Node.js or CI, use Playwright. For URL-based, server-side capture without maintaining Chromium, use a hosted screenshot API. The sections below show each route, how to export the result, how to fix CORS and incomplete renders, and which approach fits your requirements.
Choose the right conversion method
| Method | Runs in | Rendering model | Best for | Main limitation |
|---|---|---|---|---|
html2canvas |
Browser | Rebuilds a canvas from DOM and styles | Interactive pages where the user already has the element | Not pixel-perfect; CSS, CORS assets, and cross-origin iframes can fail |
html-to-image |
Browser (and compatible JavaScript runtimes) | Clones the node into SVG foreignObject, then can paint a canvas |
Convenient PNG, JPEG, Blob, SVG, or pixel-data exports | foreignObject and external assets still require browser testing |
| Playwright | Node.js, CI, or a server | Captures a page rendered by a real browser | CSS fidelity, full-page screenshots, authenticated workflows, automation | You operate browser processes and their resources |
| Hosted API | Your application calls an HTTP endpoint | Provider-managed browser or renderer | URL or HTML capture without running browsers yourself | Provider-specific limits, privacy, retention, and terms |
Decide first whether the HTML is already in the visitor’s browser. If yes, a client-side library avoids uploading private markup. If the job is a server process, needs a complete page, or must match browser pixels closely, use Playwright or an API instead.
Convert an element with html2canvas
Install and import
Install the package with your normal JavaScript package manager, then import its browser module:
Recommended Free Tools
#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.
npm install html2canvas
The following example captures an element with the ID invoice, waits for the returned canvas, and downloads a PNG.
Complete browser example
import html2canvas from '@html2canvas/html2canvas';
const element = document.querySelector('#invoice');
if (!element) throw new Error('Missing #invoice element');
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');
backgroundColor gives transparent pixels a predictable white background. scale controls output density; device-pixel-ratio is useful for sharp displays but increases memory use. Setting windowWidth and windowHeight to the element’s scroll dimensions helps include content that extends beyond its visible box.
Wait for dynamic content before capture
Call the converter only after data, images, and fonts needed by the element have loaded. For application-controlled content, await your fetch calls and render state first. For images, listen for their load events (or verify img.complete) before invoking html2canvas. A capture taken while a web font or lazy image is still loading commonly contains fallback text or blank regions.
Export the canvas correctly
Use toBlob() for files and large images
toBlob() encodes asynchronously and lets you create an object URL without holding the entire encoded image in one JavaScript string. Revoke that URL after the download lifecycle has finished. PNG is a lossless fallback and preserves transparency when the canvas background is transparent.
Free tools Windows power users keep installed
One-click scans. No signup required.
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');
For a smaller photographic file, request JPEG and provide a quality value between 0 and 1:
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.
canvas.toBlob((blob) => {
if (!blob) throw new Error('JPEG encoding failed');
// upload blob or create an object URL here
}, 'image/jpeg', 0.88);
Use toDataURL() when an inline string is required
const canvas = await html2canvas(document.querySelector('#capture'));
const dataUrl = canvas.toDataURL('image/png');
console.log(dataUrl);
A data URL keeps the complete encoded image in memory as a string, so it is a poor choice for very large captures or repeated exports. Use a Blob for downloads and uploads whenever possible. If a requested format is unsupported, toDataURL() falls back to PNG.
Fix CORS and tainted-canvas errors
A canvas becomes tainted when it contains pixels from an image origin that did not grant your page permission to read them. Calling toBlob() or toDataURL() then throws a SecurityError (or returns no usable data). This is a browser security rule, not an html2canvas bug.
Configure the image server
- Send an
Access-Control-Allow-Originresponse header from the image server. Use your exact origin for credentialed requests; use*only when that policy is appropriate. - Set
crossorigin="anonymous"on the image element before assigning itssrc. - Pass
useCORS: trueto html2canvas.
const image = new Image();
image.crossOrigin = 'anonymous';
image.src = 'https://cdn.example.com/logo.png';
image.onload = async () => {
const canvas = await html2canvas(document.querySelector('#invoice'), {
useCORS: true
});
};
If you cannot change the remote server, fetch or proxy the asset through a server you control, applying the correct CORS policy there. Do not treat a browser extension or a disabled web-security flag as a production solution.
Cross-origin iframes are a separate boundary
html2canvas cannot read the document inside an iframe hosted on another origin. Capture content at the iframe’s own origin (with that application’s cooperation) or use a browser-level workflow that is authorized to navigate and capture the page. Same-origin iframes can be handled as part of your page, subject to normal loading and styling timing.
Try html-to-image when SVG serialization fits
The html-to-image package exposes toPng, toJpeg, toBlob, toPixelData, and toSvg. Its documented approach clones the target node into an SVG foreignObject and can then paint that SVG into an off-screen canvas. This often preserves more browser CSS behavior than manually traversing styles.
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.
import { toPng, toBlob } from 'html-to-image';
const node = document.querySelector('#invoice');
const pngDataUrl = await toPng(node, { backgroundColor: '#fff' });
const blob = await toBlob(node, { backgroundColor: '#fff' });
if (!blob) throw new Error('Could not encode image');
Test the target browsers: SVG foreignObject support differs, and external fonts or images still need usable CORS responses. This library is not a way around iframe isolation or inaccessible resources.
Capture a real browser page with Playwright
Playwright launches a browser, executes scripts, applies the page’s actual CSS engine, and exposes screenshot clipping and full-page options. It is the better fit when visual fidelity matters more than a zero-dependency browser bundle.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Node.js example
import { chromium } from 'playwright';
const browser = await chromium.launch();
try {
const page = await browser.newPage({
viewport: { width: 1280, height: 900 },
deviceScaleFactor: 1
});
await page.goto('https://example.com/report', { waitUntil: 'networkidle' });
await page.screenshot({ path: 'report.png', fullPage: true });
} finally {
await browser.close();
}
Element-only and controlled captures
const report = page.locator('#report');
await report.waitFor({ state: 'visible' });
await report.screenshot({ path: 'report-card.png' });
await page.screenshot({
path: 'header.png',
clip: { x: 0, y: 0, width: 1280, height: 180 }
});
Use Playwright’s navigation, locator waits, authentication context, and request controls to make the page deterministic. Close the browser in a finally block so failed jobs do not leak processes. Full-page screenshots can be very tall; set viewport and device scale deliberately and watch memory in CI.
Or skip the browser setup
ScreenshotNeo is a hosted website screenshot API and MCP server. It is the first service to try when you want URL capture without operating a browser: it produces clean shots by accepting cookie or consent banners and removing more than 60 known consent platforms, newsletter popups, and chat widgets before capture. Each response identifies the page verdict and whether it was billed; bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing.
A single GET request can return PNG, JPEG, WebP, or PDF. The API supports full-page capture with lazy images loaded, CSS-selector element capture, dark mode, 12 device presets or 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/network idle, blocking ads/trackers/requests/resource types, custom headers/cookies/user agents/Authorization, timezone and geolocation, transparent backgrounds, image resizing, configurable-TTL caching, signed links for public <img> tags, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API, and an OpenAPI specification. Parameter names used by other screenshot APIs are accepted to ease migration. Every feature is on every plan.
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,
)
r.raise_for_status()
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}`);
if (!res.ok) throw new Error(`Screenshot failed: ${res.status}`);
const bytes = Buffer.from(await res.arrayBuffer());
await import('node:fs/promises').then(fs => fs.writeFile('shot.webp', bytes));
See the ScreenshotNeo API documentation for option names, response headers, asynchronous jobs, and signed webhooks. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients.
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 glitchesRank #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
Plans and billing
| Plan | Allowance | Price |
|---|---|---|
| Free | 1,000 shots/month | $0, no card |
| Starter | 3,000 shots | $5 |
| Growth | 15,000 shots | $15 |
| Pro | 60,000 shots | $39 |
| Scale | 250,000 shots | $99 |
| Business | 1,000,000 shots | $249 |
Yearly billing provides two months free. Only clean shots are billed, and every response includes X-Page-Verdict and X-Billed headers so your job can distinguish a successful capture from a non-billable failure or cache hit.
Create a free ScreenshotNeo account to get 1,000 screenshots each month with no card; paid plans start at $5 for 3,000 shots.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Troubleshoot incomplete or incorrect images
Blank or partially rendered output
- Wait until API data, images, and web fonts have finished loading.
- For html2canvas, set
windowWidthandwindowHeightfrom the element’s scroll dimensions. - Use an explicit scale and background instead of relying on browser defaults.
- For Playwright, wait for a meaningful locator or application-ready state rather than assuming navigation completion means the dashboard is ready.
Tainted canvas or SecurityError
- Confirm the image response includes a compatible
Access-Control-Allow-Originheader. - Set
crossoriginbeforesrcand enableuseCORS. - Proxy assets through your own origin when the remote server cannot provide CORS.
- Remember that one non-CORS image can taint the entire canvas.
CSS does not match the page
html2canvas renders only the CSS properties it understands while rebuilding a representation. Complex filters, generated content, blend modes, and browser-specific behavior can differ. Switch to Playwright for a real-browser screenshot, or test html-to-image’s SVG route in every browser you support.
Cross-origin iframe is missing
The browser prevents html2canvas from reading a foreign iframe document. Capture that document separately at its origin, obtain cooperation from the embedded application, or use an authorized browser-level capture.
Browser freezes or the file is huge
- Reduce viewport dimensions or device scale for oversized pages.
- Prefer
toBlob()and object URLs over data URLs. - Capture one element or page range instead of an unnecessarily tall full page.
- Revoke object URLs and close Playwright browsers after each job.
Privacy, reliability, and operating-cost decisions
Keep rendering in the browser when markup is private
html2canvas and html-to-image process the DOM locally, so the rendered HTML does not need to leave the user’s device. You still depend on the browser’s CORS rules and available memory.
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.
Use Playwright for repeatable server jobs
Pin your browser and Playwright versions, set explicit viewports, wait for deterministic application states, and isolate jobs. Account for browser startup time, RAM, fonts, network access, and cleanup in your worker design.
Use an API when operations matter more than browser ownership
A hosted service removes browser patching and concurrency management from your code. Before sending private pages, check the provider’s retention, regional processing, authentication, and acceptable-use terms. Configure caching only when serving a cached image is acceptable; choose a TTL that matches how often the source changes.
A practical decision checklist
- Choose html2canvas for a quick, in-browser element export with acceptable CSS approximation.
- Choose html-to-image when its SVG
foreignObjectpipeline gives the compatibility you need and you want built-in format helpers. - Choose Playwright for pixel fidelity, full-page Node.js or CI screenshots, authenticated sessions, or browser automation.
- Choose ScreenshotNeo when you want URL, PDF, bulk, MCP, or server-side capture without maintaining browser infrastructure.
- Whichever route you choose, plan for loading waits, cross-origin assets, output memory, and explicit error handling.
Frequently Asked Questions
Does html2canvas capture the browser’s address bar or other browser chrome?
No. It renders the selected DOM content inside the page; browser UI outside the document is not part of the canvas.
Can I use a data URL as an image source after conversion?
Yes. toDataURL() returns a data URL, but use a Blob and object URL for large images to avoid keeping the entire encoded file in a string.
Is a hosted screenshot API suitable for pages requiring login?
It can be, provided the service supports the authentication mechanism you need and its privacy and retention terms are acceptable. ScreenshotNeo supports custom headers, cookies, user agents, and Authorization values.
Quick Recap
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.

