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 reinstallhtml2canvas returns a canvas, not a Base64 string. Wait for the promise, call canvas.toDataURL('image/png'), then use the returned data URL as an image source or as a download link. For large captures, export with toBlob() and create a temporary object URL instead of building a very large in-memory string.
Open an html2canvas Base64 image in the browser
The shortest working pattern captures an element, converts the resulting canvas to a PNG data URL, and opens that URL in a new tab:
const canvas = await html2canvas(document.querySelector('#capture'));
const dataUrl = canvas.toDataURL('image/png');
window.open(dataUrl, '_blank');
The value returned by toDataURL() already includes its media type and Base64 payload, for example data:image/png;base64,.... Do not prepend another data:image/png;base64, string.
If the browser blocks a new tab because the call happens outside a user gesture, display the result in the current document or create the tab synchronously from a click handler. The html2canvas project describes this as a reconstructed “screenshot”: it reads DOM and CSS information rather than copying the browser’s literal pixels. See the official examples and documentation.
#1 Best Overall
- USB-C 2-in-1 storage OTG: The Lexar JumpDrive Dual Drive D40E features USB Type-A and Type-C connectors in a slim, portable form factor for easy device compatibility
- Transfer speeds up to 100MB/s: Based on internal testing, performance may vary depending upon the host device, interface, and usage conditions. 1MB=1,000,000 bytes
- Plug and Play: Widely compatible with USB Type-C smartphones, tablets, laptops, Macs, and traditional Type-A devices, no software installation required. The 360° swivel design allows for easy switching between connectors without the hassle of losing a cap
- Durable & Compact: The Lexar D40E USB memory stick features a metal enclosure, withstands temperatures from 0° to 50° C (32°F to 122°F), and is lightweight at 26g with dimensions of 70.4 x 16.9 x 11.7mm
- Security & Warranty: Securely protects files using an advanced security software solution with 256-bit AES encryption. Backed by a Lexar 3-year limited warranty
Display the result in an <img> element
Assign the data URL directly to src. This is useful for a preview, a gallery, or replacing the captured element with its rendered image.
async function showCapture() {
const element = document.querySelector('#capture');
const canvas = await html2canvas(element);
const dataUrl = canvas.toDataURL('image/png');
const image = new Image();
image.alt = 'Screenshot of the captured content';
image.src = dataUrl;
image.style.maxWidth = '100%';
document.querySelector('#preview').replaceChildren(image);
}
showCapture().catch(console.error);
Example markup:
<div id="capture">Content to render</div>
<div id="preview"></div>
Use image.onload if later code needs the displayed dimensions. The image can be styled normally because a data URL is a valid image source.
Download the Base64 image as a PNG
Create an anchor, put the data URL in href, set download, and activate it. This follows the project’s official download example.
async function downloadCapture() {
const canvas = await html2canvas(document.querySelector('#capture'));
const dataUrl = canvas.toDataURL('image/png');
const link = document.createElement('a');
link.download = 'capture.png';
link.href = dataUrl;
link.click();
}
downloadCapture().catch(console.error);
Call this from a button’s click handler when possible:
document.querySelector('#download').addEventListener('click', () => {
downloadCapture().catch(error => console.error('Capture failed:', error));
});
The download attribute is a filename suggestion. Browser security rules and cross-origin navigation policies can affect downloads in unusual embedding situations, but same-origin pages generally follow this pattern.
Rank #2
- High-speed USB 3.0 performance of up to 150MB/s(1) [(1) Write to drive up to 15x faster than standard USB 2.0 drives (4MB/s); varies by drive capacity. Up to 150MB/s read speed. USB 3.0 port required. Based on internal testing; performance may be lower depending on host device, usage conditions, and other factors; 1MB=1,000,000 bytes]
- Transfer a full-length movie in less than 30 seconds(2) [(2) Based on 1.2GB MPEG-4 video transfer with USB 3.0 host device. Results may vary based on host device, file attributes and other factors]
- Transfer to drive up to 15 times faster than standard USB 2.0 drives(1)
- Sleek, durable metal casing
- Easy-to-use password protection for your private files(3) [(3)Password protection uses 128-bit AES encryption and is supported by Windows 7, Windows 8, Windows 10, and Mac OS X v10.9 plus; Software download required for Mac, visit the SanDisk SecureAccess support page]
Use a Blob URL for large captures
toDataURL() encodes the entire image into a JavaScript string. That string can consume substantial memory and may hit browser URL-length limits. For a large or full-page capture, use toBlob(), then create an object URL:
async function downloadLargeCapture() {
const canvas = await html2canvas(document.querySelector('#capture'));
canvas.toBlob((blob) => {
if (!blob) {
console.error('The browser could not create an image blob.');
return;
}
const objectUrl = URL.createObjectURL(blob);
const link = document.createElement('a');
link.download = 'capture.png';
link.href = objectUrl;
link.click();
URL.revokeObjectURL(objectUrl);
}, 'image/png');
}
downloadLargeCapture().catch(console.error);
Revoke the object URL after the link has been activated so the browser can release the associated memory. If you need the URL for a visible preview, revoke it only after the image has loaded and is no longer needed.
Choose PNG, JPEG, or another format
PNG is the default and required export format for toDataURL(). You may request another MIME type:
const jpegUrl = canvas.toDataURL('image/jpeg', 0.85);
const webpUrl = canvas.toDataURL('image/webp', 0.85);
The second argument is a quality hint for lossy formats. If a requested type is unsupported, the browser falls back to PNG, so inspect the beginning of the returned string when the format matters. Transparent pixels are preserved by PNG; JPEG has no transparency and is usually smaller for photographic content.
Capture the right area and dimensions
Pass the element you want to render:
const element = document.querySelector('.invoice');
const canvas = await html2canvas(element, {
backgroundColor: '#ffffff'
});
For content that extends beyond the visible viewport, set capture dimensions from the element’s scroll area:
Rank #3
- What You Get - 2 pack 64GB genuine USB 2.0 flash drives, 12-month warranty and lifetime friendly customer service
- Great for All Ages and Purposes – the thumb drives are suitable for storing digital data for school, business or daily usage. Apply to data storage of music, photos, movies and other files
- Easy to Use - Plug and play USB memory stick, no need to install any software. Support Windows 7 / 8 / 10 / Vista / XP / Unix / 2000 / ME / NT Linux and Mac OS, compatible with USB 2.0 and 1.1 ports
- Convenient Design - 360°metal swivel cap with matt surface and ring designed zip drive can protect USB connector, avoid to leave your fingerprint and easily attach to your key chain to avoid from losing and for easy carrying
- Brand Yourself - Brand the flash drive with your company's name and provide company's overview, policies, etc. to the newly joined employees or your customers
const element = document.querySelector('#capture');
const canvas = await html2canvas(element, {
windowWidth: element.scrollWidth,
windowHeight: element.scrollHeight
});
These options influence html2canvas’s DOM reconstruction; they do not bypass browser canvas limits. Extremely wide or tall canvases can be truncated or empty. Check canvas.width and canvas.height before exporting.
Cross-origin images, CORS, and tainted canvases
Images loaded from another origin must grant permission through suitable CORS response headers if you want html2canvas to read them. A client-side option alone cannot override the browser’s same-origin policy.
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 →const canvas = await html2canvas(document.querySelector('#capture'), {
useCORS: true
});
useCORS: true works only when the image server permits the requesting origin, typically with an Access-Control-Allow-Origin response header. If the remote server does not provide CORS, serve the asset from your own origin or use a server-side proxy that you control and configure safely. Cross-origin iframes remain inaccessible to browser JavaScript.
A tainted canvas may still appear on screen, but reading it with toDataURL() or toBlob() can throw a security exception. Fix the resource policy rather than trying to add a second Base64 prefix.
Why the output is blank, incomplete, or different
Blank output or data:,
MDN documents data:, when a canvas has zero width or height or when its dimensions exceed the browser’s maximum canvas size. Confirm that the selected element exists, is laid out, and has non-zero dimensions. Reduce scale or split a very large capture into sections.
Rank #4
- GOOD VALUE PACKAGE - 1 Pack 32GB Memory Stick USB 2.0 Flash Drives with great cost performance and high quality.
- BIG CAPACITY - The available capacity: 29.10GB-29.8GB, You can save the data of movies, music, photos, designs, programs, manuals, handouts in a high speed.Good performance in digital data storing, transferring and sharing with families, friends, workmates, clients and machines.
- EASY TO USE & PLUG AND WORK - Support windows 7 / 8 / 10 / Vista / XP / 2000 / ME / NT Linux and Mac OS, Compatible with USB2.0 and below.
- TWISTTURN DESIGN & EASY CARRY - The metal clip rotates 360° round the ABS plastic body which with rubber oil skin feeling finish. The capless design can avoid lossing of cap, and providing efficient protection to the USB port.
- WARRANTY & SUPPORT - SIMMAX logo is laser printed on the USB connector surface, our products are of good quality and we promise that any problem about the product within one year since you buy.
Images or fonts are missing
Wait until assets have loaded before calling html2canvas. Cross-origin resources need CORS permission, and inaccessible fonts or images cannot be read. A delayed capture can help with late-rendering content, but it cannot grant access to blocked resources.
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 glitchesThe result does not match the visible page
html2canvas approximates the page from DOM and CSS data. Unsupported CSS, browser differences, animations, and inaccessible resources can change the result. Freeze animations, hide transient controls, and capture after the layout has settled. It is not a pixel-perfect browser compositor or a way to capture cross-origin iframe pixels.
The canvas is cut off
Inspect the requested dimensions and browser limits. Use the element’s scroll dimensions through windowWidth and windowHeight, but avoid creating a canvas larger than the browser can allocate. For long documents, capture logical sections separately and combine them on the server or in an image editor.
The download does nothing
Check the console for a security exception, make sure the function runs after a user gesture, and verify that the data URL is non-empty. Switch to the Blob approach if the data URL is too large. Do not revoke an object URL before the browser has had a chance to start the download.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.A complete button example
This page captures a card, previews it, and downloads a PNG while reporting failures:
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Best Value
- 【16GB Flash Drive】USB flash drives with 16GB capacity, meet your needs of daily use on work, school, home and travelling for photos, music, videos, files storage and transfer. IMEASON thumb drives can be used to store different files, easy to data backup.
- 【Metal Swivel Cap Design】USB thumb drive is metal swivel cover provides extra protection for the usb thumbdrive connector, no usb drive cap to lose; keychain design makes it easier to carry without worrying lose it.
- 【Wide Compatibility】USB drive supports Windows 7/8/10/11 / Vista / XP / Unix / 2000 / ME / NT Linux and Mac OS, also Supports USB 2.0 and 1.1 ports. USB Stick support TV, desktop, notebook computer, car, audio and other device. The USB Memory Stick is your great data storage and transfer companion with traveling and working.
- 【Easy to use】usb memory stick is plug and play without any software installation. Just simply plug the Flashdrive into the port of your USB-compatible devices such as computer, laptop to start data storage or transmission.
- 【What You Get】16 GB USB Flash Drive Thumb Drive, The default format of the usb storage flash drive is FAT32.
<button id="save" type="button">Save card</button>
<section id="card">
<h1>Quarterly report</h1>
<p>Revenue and expenses</p>
</section>
<div id="preview"></div>
<script type="module">
import html2canvas from 'https://cdn.jsdelivr.net/npm/[email protected]/+esm';
document.querySelector('#save').addEventListener('click', async () => {
const button = document.querySelector('#save');
button.disabled = true;
try {
const canvas = await html2canvas(document.querySelector('#card'), {
useCORS: true,
backgroundColor: '#ffffff'
});
const preview = new Image();
preview.alt = 'Saved report preview';
preview.src = canvas.toDataURL('image/png');
document.querySelector('#preview').replaceChildren(preview);
canvas.toBlob((blob) => {
if (!blob) throw new Error('PNG encoding failed');
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = 'quarterly-report.png';
link.click();
URL.revokeObjectURL(url);
}, 'image/png');
} catch (error) {
console.error(error);
alert('The capture could not be exported. Check CORS and canvas dimensions.');
} finally {
button.disabled = false;
}
});
</script>
Pin a version in production according to your dependency policy; the example’s import URL is only a runnable demonstration. The export APIs used here are built into browsers, while html2canvas supplies the canvas.
Performance, reliability, and privacy considerations
- Prefer Blob for large output: it avoids one giant Base64 string and makes memory usage easier to control.
- Capture only what you need: smaller elements finish faster and are less likely to hit canvas limits.
- Wait for stable layout: fonts, images, lazy content, and animations can otherwise produce inconsistent captures.
- Handle errors: html2canvas returns a promise, so use
try…catchand provide a visible failure state. - Protect sensitive data: the resulting data URL contains the captured pixels. Do not log it or place it in analytics events.
- Clean up: revoke Blob URLs and discard temporary canvases when they are no longer needed.
Or skip the browser setup
If you need a service-generated screenshot rather than a browser-side html2canvas reconstruction, ScreenshotNeo accepts one GET request and returns PNG, JPEG, WebP, or PDF. It removes cookie-consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, timeouts, failed loads, and cache hits are not billed. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. The Free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 shots.
Use the ScreenshotNeo API documentation for all options. A direct cURL request:
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 data = Buffer.from(await res.arrayBuffer());
await import('node:fs/promises').then(fs => fs.writeFile('shot.webp', data));
ScreenshotNeo responses include X-Page-Verdict and X-Billed headers so your application can distinguish a clean shot from a failed or non-billable result. Create a free ScreenshotNeo account to get 1,000 screenshots a month with no card.
Free tools Windows power users keep installed
One-click scans. No signup required.
Frequently asked questions
Is the html2canvas result already Base64?
No. The promise resolves to an HTMLCanvasElement. Calling toDataURL() produces the data URL containing the Base64-encoded image.
Can I open the data URL in a new tab?
Yes: pass the returned string to window.open(), subject to popup-blocker rules. Displaying it in an <img> is more reliable when the call is asynchronous.
Which export method should I use?
Use toDataURL() for small previews and simple links. Use toBlob() with URL.createObjectURL() for large captures or downloads.
Can html2canvas capture an embedded third-party iframe?
Not when browser security prevents access to that iframe’s document or pixels. Same-origin content or a cooperative integration is required.
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.




