Free tools Windows power users keep installed
One-click scans. No signup required.
To convert an HTML element to a PNG in React, attach a ref to the rendered element, wait for its images and fonts to load, pass that element to html2canvas, and download the returned canvas as a PNG. This works well for cards, invoices, charts, and other same-origin UI fragments. It reconstructs the element from DOM and CSS rather than taking the browser’s native screenshot, so complex or unsupported CSS can differ from what you see on screen.
Client-side conversion with html2canvas
The current package documentation uses @html2canvas/html2canvas. Install it with your preferred package manager:
npm install @html2canvas/html2canvas
# or
yarn add @html2canvas/html2canvas
# or
pnpm add @html2canvas/html2canvas
The capture API is asynchronous and resolves to a canvas. Keep the target mounted in the document while the capture runs.
Complete React component
import { useRef } from 'react';
import html2canvas from '@html2canvas/html2canvas';
export function CardExport() {
const captureRef = useRef(null);
async function downloadPng() {
const element = captureRef.current;
if (!element) return;
// Wait for images that are already in the document.
const images = Array.from(element.querySelectorAll('img'));
await Promise.all(
images.map((img) => {
if (img.complete) return Promise.resolve();
return new Promise((resolve) => {
img.addEventListener('load', resolve, { once: true });
img.addEventListener('error', resolve, { once: true });
});
})
);
if (document.fonts?.ready) {
await document.fonts.ready;
}
const canvas = await html2canvas(element, {
backgroundColor: null,
scale: window.devicePixelRatio,
useCORS: true,
});
const link = document.createElement('a');
link.download = 'card.png';
link.href = canvas.toDataURL('image/png');
link.click();
}
return (
<>
Quarterly report
This element is exported as a PNG.
>
);
}
The readiness waits are application safeguards: they prevent an export from starting while images or fonts are still loading. An image that fails to load is allowed to resolve so one broken asset does not leave the button waiting forever; you can instead surface an error if that is preferable for your application.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minute#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.
Use a Blob for larger files
toDataURL() creates a base64 string in memory. For larger captures, write a Blob and download an object URL, then revoke it:
canvas.toBlob((blob) => {
if (!blob) return;
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.download = 'card.png';
link.href = url;
link.click();
URL.revokeObjectURL(url);
}, 'image/png');
Keep the object URL alive until the browser has started the download. If a particular browser needs more time, revoke it from a short-lived cleanup callback rather than immediately.
Important html2canvas options
Options change the pixels, transparency, and area that are rendered. Set them deliberately rather than copying defaults without checking your design.
| Option | What it controls | Practical implication |
|---|---|---|
scale |
Output pixel density | Using window.devicePixelRatio makes a high-density export, but increases memory and canvas dimensions. |
backgroundColor |
Canvas background | null requests transparency where the captured element does not paint its own background. |
useCORS |
Cross-origin image loading attempt | The remote image server must send an appropriate CORS header; this option cannot bypass browser policy. |
allowTaint |
Whether potentially tainting images may be drawn | Allowing them can make the canvas unreadable, so it does not solve export security errors. |
width, height |
Capture dimensions | Set these when you need a fixed output size instead of the element’s current dimensions. |
windowWidth, windowHeight |
Virtual viewport used during rendering | Useful when responsive CSS must be evaluated at a particular viewport. |
x, y, scrollX, scrollY |
Origin and scroll position | These affect which portion of a larger layout is reconstructed. |
For a complete option list, consult the html2canvas configuration documentation.
Capture the full element, not just the visible viewport
A long element can extend beyond the viewport. Before capturing, measure its scroll dimensions and pass them as dimensions when appropriate:
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.
const element = captureRef.current;
const canvas = await html2canvas(element, {
width: element.scrollWidth,
height: element.scrollHeight,
windowWidth: element.scrollWidth,
windowHeight: element.scrollHeight,
scale: 1,
});
Very large canvases are subject to browser-specific size and memory limits. A blank or truncated result usually means the requested bitmap is too large; reduce scale, capture sections separately, or export a server-side screenshot instead.
What html2canvas can and cannot reproduce
html2canvas builds an image from the DOM and style information available to JavaScript. The project documentation warns that the result “may not be 100% accurate to the real representation” because it does not make an actual screenshot. Unsupported CSS, browser rendering differences, filters, and complex effects can therefore look different.
- The target must be a DOM element that exists when capture starts.
- Canvas and SVG content generally need to be available in a form the library can read.
- Cross-origin iframes cannot be read because of browser same-origin restrictions.
- Remote fonts, stylesheets, and images must be reachable and permitted for the page’s origin.
- Animations or blinking cursors can produce nondeterministic output; pause them or apply a capture-only class.
If your requirement is a browser-accurate page screenshot, DOM reconstruction is the wrong fidelity model. Use a real browser renderer or a managed screenshot service and evaluate its privacy, operational, and cost implications.
Cross-origin images and tainted canvases
Images from another origin are the most common reason exports omit assets or fail when read back. useCORS: true asks the browser to make a CORS request, but the image host must opt in with an appropriate Access-Control-Allow-Origin response. You cannot override that policy from React.
If you control the asset server, configure CORS for the application origin and ensure the image request is cacheable as intended. If you do not control it, serve the asset through a server-side proxy that you are authorized to operate, or replace it with a same-origin copy. An iframe from another origin remains inaccessible even if it visually appears inside your page.
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.
A canvas becomes tainted when it contains pixels that the browser does not permit JavaScript to read. Calling toDataURL() or toBlob() on such a canvas then raises a security error. Setting allowTaint: true permits drawing but does not make readback safe; it can leave you with an unusable export.
Reliable capture workflow
- Render a dedicated export surface. Keep the section attached to the document and give it explicit dimensions, colors, and spacing.
- Freeze transient UI. Disable animations, hover states, carousels, and loading placeholders while the capture is in progress.
- Wait for assets. Await image completion and
document.fonts.readywhen custom fonts affect layout. - Choose dimensions and scale. Higher scale improves detail but increases memory use and the chance of hitting canvas limits.
- Capture and handle failure. Wrap the asynchronous call in
try/catch, restore any temporary styles infinally, and re-enable the button. - Download or upload. Use
toDataURLfor small files ortoBlobfor larger files and network uploads.
Troubleshooting
Images are missing
Open the image URL directly and inspect the response headers. Add CORS headers on the asset server, use useCORS: true, or route the image through an authorized same-origin proxy. A broken URL, authentication cookie, or lazy image that has not entered the DOM also produces a missing image.
“Tainted canvas” or a security exception
At least one drawn pixel came from a disallowed origin. Fix the asset server’s CORS response or remove/proxy the asset. Do not rely on allowTaint when you need a downloadable PNG.
An iframe is blank
A cross-origin iframe’s document cannot be inspected by page JavaScript. Capture content you own in the parent page, or use a server-side browser that is authorized to access the target.
The PNG does not match the page
Check unsupported CSS and responsive breakpoints, then compare the capture at a fixed windowWidth. Pause animation and ensure fonts have loaded. html2canvas is a reconstruction, not a native browser screenshot.
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
The output is blank or cut off
Log element.scrollWidth, element.scrollHeight, and the chosen scale. Reduce the bitmap size, capture in sections, or move to a real browser renderer when the page exceeds browser canvas limits.
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 matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallThe button does nothing
Confirm that the ref is attached to the element, that the component is mounted, and that the click handler is not blocked by another overlay. Log errors around the awaited html2canvas call and check the browser console for blocked resources.
When a server-side screenshot is a better fit
Choose a server or managed renderer when the PNG must represent a complete page, include cross-origin resources you are allowed to fetch, run without a user’s browser, or be generated consistently for social cards and reports. Compare solutions by rendering fidelity, asset access, viewport and pixel controls, privacy, reliability, and the cost of operating a browser or sending HTML to an external provider.
A hosted HTML-to-image service documents HTML and screenshot endpoints that return PNG output with API-key authentication. Its documentation establishes the service category, not universal pricing, retention, or availability terms; verify those details with the provider before adopting it.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server for developers. It accepts a URL and returns PNG, JPEG, WebP, or PDF. Before capture, it accepts cookie and consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step 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 whether it was billed.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →One GET request is enough:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo documentation for all options, including full-page lazy-image loading, CSS-selector element capture, dark mode, device presets and custom viewports, retina scale, PDF paper and page controls, HTML/CSS input, custom JavaScript and CSS, pre-capture clicks, selector hiding, selector or network-idle waits, request and resource blocking, headers, cookies, user agents, Authorization, timezone and geolocation, transparent backgrounds, resizing, configurable-TTL caching, signed image links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, usage data, and the OpenAPI specification. Existing parameter names used by other screenshot APIs also work, which can simplify migration.
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.
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 fs = await import('node:fs/promises');
await fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));
ScreenshotNeo also provides an MCP server with take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account to get an API key.
Client library or managed API?
| Requirement | html2canvas in React | ScreenshotNeo |
|---|---|---|
| Capture a component already rendered in the user’s browser | Strong fit; no server request required | Requires a reachable URL |
| Native browser screenshot fidelity | Not guaranteed; reconstructs DOM and CSS | Managed website screenshot workflow |
| Cookie banners, popups, and chat widgets | Must be hidden or handled in your app | Removed before capture, with controls to disable steps |
| Cross-origin assets | Requires CORS or an authorized proxy | Fetches the target page as a screenshot service; confirm access rules for your content |
| AI-agent integration | Not provided by the library | MCP tools are available |
| Billing model | No library capture charge; you operate the browser context | Only clean shots are billed; failed loads and listed non-page results are not billed |
Frequently Asked Questions
Can I convert an HTML string directly with html2canvas?
html2canvas expects a DOM element. Render the markup in React first, attach a ref, and capture that mounted element.
Does the PNG include transparent pixels?
Set backgroundColor: null and avoid an opaque background on the captured element. Any painted element background remains opaque.
Why should I use toBlob instead of toDataURL?
A Blob avoids keeping the entire PNG as a base64 string, which is preferable for larger files or uploads.
Can this run during server-side rendering?
No. html2canvas depends on browser DOM, layout, fonts, and canvas APIs, so invoke it in a client-side event or effect after mounting.
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.

