To download an html2canvas render as a PNG, wait for html2canvas() to return a canvas, convert it with canvas.toDataURL('image/png'), assign the data URL to an anchor, set a .png filename, and click that anchor:
html2canvas(element).then(canvas => {
const link = document.createElement('a');
link.download = 'screenshot.png';
link.href = canvas.toDataURL('image/png');
link.click();
});
Here, element is the DOM node you want to render. The download works entirely in the browser, but the resulting image is a reconstruction of the DOM, not a pixel capture of the browser window.
Download a PNG from an html2canvas canvas
Install or load html2canvas in your page, select the element, and run the export after the page content you need is available. The Promise-based version is convenient in an async event handler:
async function saveElementAsPng() {
const element = document.querySelector('#invoice');
if (!element) {
throw new Error('The #invoice element was not found');
}
const canvas = await html2canvas(element);
const link = document.createElement('a');
link.download = 'invoice.png';
link.href = canvas.toDataURL('image/png');
link.click();
}
document.querySelector('#save-button').addEventListener('click', saveElementAsPng);
The filename is only a suggestion to the browser, so use a meaningful name ending in .png. Calling toDataURL('image/png') asks the Canvas API for a PNG data URL; assigning it to href and clicking the anchor starts the download.
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
- 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
Complete minimal page
This example assumes html2canvas has already been loaded. Replace the script URL with the version and delivery method used by your application.
<button id='save-button' type='button'>Save PNG</button>
<section id='card'>
<h1>Project summary</h1>
<p>This section becomes screenshot.png.</p>
</section>
<script>
document.querySelector('#save-button').addEventListener('click', async () => {
const canvas = await html2canvas(document.querySelector('#card'));
const link = document.createElement('a');
link.download = 'screenshot.png';
link.href = canvas.toDataURL('image/png');
link.click();
});
</script>
What html2canvas actually captures
html2canvas walks the DOM and supported styles, then paints its own representation onto a canvas. It does not take a literal screenshot of pixels already produced by the browser. Consequently, a valid PNG can still differ from what a user sees.
- Unsupported or partially supported CSS can change spacing, effects, or visual details.
- Cross-origin iframes cannot be read because of browser security restrictions.
- Images and background images may be skipped when origin rules prevent canvas export.
- Dynamic content must be present when html2canvas runs; otherwise it cannot appear in the render.
Use this method when a DOM-based rendering is acceptable. If you require an exact browser-pixel capture, use a browser automation or screenshot service instead of treating html2canvas as a camera.
Make the export reliable
Check the target and handle failures
Always verify the selector before calling html2canvas and catch rejected Promises so a failed resource does not silently look like a successful download.
async function downloadPng(selector, filename = 'screenshot.png') {
const element = document.querySelector(selector);
if (!element) {
throw new Error(`No element matches ${selector}`);
}
try {
const canvas = await html2canvas(element, {
onError(error) {
console.error('html2canvas resource error:', error);
}
});
const link = document.createElement('a');
link.download = filename.endsWith('.png') ? filename : `${filename}.png`;
link.href = canvas.toDataURL('image/png');
link.click();
} catch (error) {
console.error('PNG capture failed:', error);
throw error;
}
}
The configuration reference describes onError for failed resources such as images, SVG files, and background images. Keep the browser console open while diagnosing a missing asset.
Rank #2
- 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
Render a long element at its full dimensions
A tall element can be clipped if the rendering window is smaller than the element’s scroll area. The html2canvas FAQ recommends passing the element’s scroll dimensions:
const element = document.querySelector('#long-page');
const canvas = await html2canvas(element, {
windowWidth: element.scrollWidth,
windowHeight: element.scrollHeight
});
const link = document.createElement('a');
link.download = 'long-page.png';
link.href = canvas.toDataURL('image/png');
link.click();
This changes the virtual rendering window; it does not remove the browser’s maximum canvas dimensions or maximum pixel area.
Wait for content before rendering
Call html2canvas only after the target has been inserted and populated. In an application that loads data asynchronously, put the capture action after the data-rendering Promise resolves. For user-triggered captures, the click handler is often the simplest place because the visible state already exists. If a component still changes during capture, pause that update or capture after its final state is committed.
Cross-origin images, CORS, and tainted canvases
Canvas security rules determine whether the finished canvas can be read and exported. With allowTaint false, which is the default described by the html2canvas FAQ, images that would taint the canvas are skipped. A skipped image can leave an otherwise valid PNG incomplete.
Use CORS when the image server permits it
const canvas = await html2canvas(document.querySelector('#gallery'), {
useCORS: true,
onError(error) {
console.error(error);
}
});
useCORS: true helps only when the remote image server sends suitable CORS response headers. It cannot override another server’s policy. Configure the image host to allow the requesting origin, and make sure the image URL is reachable from the browser.
Rank #3
- 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.
Use a proxy when direct CORS is not available
When you control a server-side proxy, route remote assets through that proxy and configure html2canvas to use it according to the library’s configuration reference. The proxy must fetch the asset and return it with headers that let the browser use it in the canvas. Do not assume that adding useCORS alone fixes an image host that sends no CORS headers.
Inspect the console and resource requests
Open Developer Tools, look for blocked image or SVG requests, and inspect the response headers. The onError callback can log failures, but it cannot make an inaccessible resource readable. Cross-origin iframes remain inaccessible even when ordinary image requests are configured correctly.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows 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 reinstallData URL versus a Blob download
The short official pattern uses a data URL. For a larger canvas, a Blob-based download avoids keeping the entire encoded data URL string in JavaScript memory at once. The two approaches produce a downloadable PNG; the supplied material does not establish a speed advantage for either one.
const canvas = await html2canvas(document.querySelector('#card'));
canvas.toBlob(blob => {
if (!blob) {
throw new Error('The browser could not create a PNG blob');
}
const objectUrl = URL.createObjectURL(blob);
const link = document.createElement('a');
link.download = 'card.png';
link.href = objectUrl;
link.click();
URL.revokeObjectURL(objectUrl);
}, 'image/png');
The callback is asynchronous. Revoke the object URL after initiating the download so it does not remain allocated indefinitely. Keep the data-URL version when you want the smallest, clearest implementation or need to put the encoded image directly into another API.
Why a PNG can be blank, incomplete, or unexpectedly small
Blank output
- The canvas is too large. Browser canvas limits are approximate and vary by browser, operating system, hardware, and updates. An oversized canvas can be blank or only partly rendered without a useful error.
- The target is empty or hidden. Confirm the selector, inspect the element at capture time, and ensure its content has finished rendering.
- Resources failed. Check console errors and network responses for images, SVG files, and backgrounds.
- A cross-origin frame is involved. Browser security prevents html2canvas from reading a cross-origin iframe.
Missing images
Use useCORS: true only when the image server supplies appropriate CORS headers. Otherwise, configure a suitable proxy or serve the asset from an origin your page can access. With the default allowTaint: false, html2canvas skips images that would taint the canvas rather than producing an exportable but unreadable canvas.
Rank #4
- 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
Cut-off long pages
Pass windowWidth: element.scrollWidth and windowHeight: element.scrollHeight, then check the total pixel area. A browser may accept the call but render only part of an element when its dimension or area limit is exceeded.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
CSS does not match the page
Compare the CSS used by html2canvas with the library’s supported properties. The library reconstructs styles manually, so unsupported properties, browser effects, and complex layout features may not be reproduced. Simplify the capture-specific styling or use a real browser screenshot tool when fidelity is essential.
Approximate canvas limits
The html2canvas FAQ lists these rough current-evergreen-browser references. They are guidance, not guarantees, and mobile Safari limits depend on device RAM.
| Browser | Approximate maximum dimension | Approximate maximum area |
|---|---|---|
| Chrome / Chromium | 32,767 px | 268 million pixels |
| Firefox | 32,767 px | 472 million pixels |
| Safari desktop | 32,767 px | Similar to Chrome |
| Safari on iOS | Lower and device-dependent | Depends on device RAM |
For a practical estimate, multiply the intended canvas width by its height before rendering. Retina-style scaling or a very wide, very tall page can exceed the area limit even when neither individual dimension looks extreme. If the page is larger than the safe canvas size, capture separate sections and combine them outside the browser, or use a screenshot service that handles full-page capture.
Performance, reliability, and privacy considerations
- Rendering cost: html2canvas must traverse the target DOM and paint it, so larger and more complex elements require more work than small cards.
- Memory: the canvas stores raw pixels, and a data URL adds an encoded representation. Prefer a Blob workflow when the encoded string itself is unnecessary.
- Determinism: freeze animations, finish data loading, and use a stable viewport when repeatable output matters.
- Failure detection: treat a returned canvas as a rendering result, not proof that every image loaded. Check console messages and use
onError. - Security: never weaken origin protections merely to force an export. Configure CORS or a controlled proxy for assets you are authorized to use.
Or skip the browser setup
If you need a server-side screenshot rather than a DOM reconstruction, ScreenshotNeo returns a PNG, JPEG, WebP, or PDF from one request. Its cleanup steps accept cookie or consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be disabled. Only clean shots are billed: 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.
Recommended Free Tools
Use the documented API examples at ScreenshotNeo docs:
Best Value
- 【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.
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}`);
ScreenshotNeo also provides an MCP server with take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. It supports full-page captures with lazy images loaded, CSS-selector element capture, device presets, custom viewport and retina scale, PDF controls, custom CSS and JavaScript, click and wait actions, request blocking, headers, cookies, user agents, authorization, timezone and geolocation, transparent backgrounds, resizing, configurable caching, signed links, 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 also work.
The Free plan includes 1,000 shots each month with no card. Paid plans start at $5 for 3,000 shots; yearly billing gives two months free, and every feature is available on every plan. Create a free ScreenshotNeo account to try it.
FAQ
Can I save the same canvas more than once?
Yes. A canvas can be converted to a PNG data URL each time you need an export. Generate a new filename for each download if you want to preserve multiple captures.
Does the PNG include browser controls or scrollbars?
No. html2canvas receives a DOM element and paints that element; browser chrome outside the page is not part of the target node.
Why does a transparent-looking area become a solid color?
The result follows the canvas rendering configuration and the styles html2canvas can reconstruct. Inspect the element’s background and capture-specific CSS when transparent areas do not match expectations.
Frequently Asked Questions
Can I save the same canvas more than once?
Yes. Convert the canvas to a PNG data URL again and use a different filename for each download.
Does the PNG include browser controls or scrollbars?
No. html2canvas paints the selected DOM element, not browser chrome outside the page.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Why does a transparent-looking area become a solid color?
Check the element’s background and the styles html2canvas can reconstruct; the exported canvas follows that rendered configuration.
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.

