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 minuteTo convert an HTML element to a downloadable PNG, install @html2canvas/html2canvas, select the element, await html2canvas(element), turn the returned canvas into a PNG data URL, and click a temporary download link. The complete pattern is:
import html2canvas from '@html2canvas/html2canvas';
const element = document.querySelector('#capture');
if (!element) throw new Error('Element #capture was not found');
const canvas = await html2canvas(element);
const link = document.createElement('a');
link.download = 'screenshot.png';
link.href = canvas.toDataURL('image/png');
link.click();
This runs in the browser and reconstructs the element from its DOM and styles; it is not a native browser screenshot. That distinction explains most differences, missing images, and sizing problems.
Install html2canvas and prepare an element
Install the current package in the project that will run in a browser:
npm install @html2canvas/html2canvas
Then import it in your application. You can also load a built release in a script tag, following the project’s getting-started instructions. The capture target must be a real DOM element, such as a card, invoice, chart, or section with an id or class.
#1 Best Overall
- 16MP Sensor: Captures detailed photos with a CMOS sensor for everyday shooting
- Optical Zoom: 4x optical zoom with a 27mm wide angle lens for flexible framing indoors or outdoors
- Full HD Video: Records 1080p video for travel clips, family moments, or simple vlogging
- Memory Support: Works with Class 10 SD, SDHC, or SDXC cards up to 512GB
- LCD Screen and Battery: 2.7in LCD screen with 2 AA alkaline batteries for convenient on-the-go use
<section id="capture">
<h1>Monthly report</h1>
<p>Revenue increased 18%.</p>
</section>
<button id="save" type="button">Download PNG</button>
Run the capture after the element exists and after any application state needed for the image has been rendered. Because html2canvas returns a Promise, use await in an async function or attach .then().
Complete browser example: convert one element to a PNG
This example includes a button handler, a missing-element check, and the download step shown by the project documentation.
import html2canvas from '@html2canvas/html2canvas';
const saveButton = document.querySelector('#save');
saveButton.addEventListener('click', async () => {
const element = document.querySelector('#capture');
if (!element) {
throw new Error('Element #capture was not found');
}
try {
const canvas = await html2canvas(element);
const link = document.createElement('a');
link.download = 'screenshot.png';
link.href = canvas.toDataURL('image/png');
link.click();
} catch (error) {
console.error('Could not create the image', error);
}
});
canvas.toDataURL('image/png') is the dependable baseline because browsers are required to support PNG. The resulting file is generated locally by the browser; no upload is required by html2canvas itself.
Improve sharpness, crop the capture, and omit controls
Use device-pixel scaling for a sharper image
A high-density display can make a one-CSS-pixel canvas look soft when exported. Pass the device pixel ratio as the scale option:
const canvas = await html2canvas(element, {
scale: window.devicePixelRatio
});
This increases the pixel dimensions of the output. It also increases memory use and processing time, so reduce the scale when a very large element approaches browser canvas limits.
Capture a specific rectangle
To crop the rendered result, provide x, y, width, and height:
const canvas = await html2canvas(element, {
x: 20,
y: 10,
width: 800,
height: 450
});
These coordinates describe the area to render. If the crop is relative to a larger layout, first verify the element’s position and dimensions in the browser.
Leave buttons and other UI out of the image
Add data-html2canvas-ignore to an element that should not appear:
Rank #2
- 16MP Sensor: Captures detailed photos with a CMOS sensor for everyday shooting
- Optical Zoom: 5x optical zoom with a 28mm wide angle lens for flexible framing indoors or outdoors
- Full HD Video: Records 1080p video for travel clips, family moments, or simple vlogging
- Memory Support: Works with Class 10 SD, SDHC, or SDXC cards up to 512GB
- LCD Screen and Battery: 2.7in LCD screen and a rechargeable lithium-ion battery for on-the-go use
<button data-html2canvas-ignore>Download</button>
For a rule in JavaScript, use ignoreElements. The callback should return true for nodes to omit:
const canvas = await html2canvas(element, {
ignoreElements: node => node.matches('. editor-only, [data-private-control]')
});
Remove the accidental space in the selector if you copy that example into a real project:
const canvas = await html2canvas(element, {
ignoreElements: node => node.matches('.editor-only, [data-private-control]')
});
Understand what html2canvas can and cannot reproduce
html2canvas traverses the DOM, collects information available to the page, and builds a representation on a canvas. It does not ask the browser for a native screenshot. The project documentation therefore cautions that the result may not be 100% accurate to the real representation.
CSS support is selective
Only CSS properties implemented by the library are rendered correctly. A page can look right in Chrome while its exported image differs in a shadow, filter, blend mode, gradient, layout detail, or other unsupported property. Check the project’s supported-features documentation for the properties used by your design, then test the actual component rather than assuming visual parity.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Fonts, timing, and application state matter
Capture after the target has reached the state you want to publish. If your code changes classes, expands a panel, or inserts data asynchronously, call html2canvas after that update has been painted. For repeatable exports, keep the target’s width, content, and styles stable while the Promise runs.
Canvas size is not unlimited
Browser and device canvas limits vary. Oversized captures can be blank, partially rendered, or fail without a useful universal maximum. Reduce the target area or scale, and avoid combining a very tall page with a high device-pixel ratio. When capturing content that extends beyond the viewport, set the virtual window dimensions to the element’s scroll dimensions:
const canvas = await html2canvas(element, {
windowWidth: element.scrollWidth,
windowHeight: element.scrollHeight
});
This is a practical correction for cut-off content, not a guarantee that every browser can allocate an arbitrarily large canvas.
Why images are missing: CORS and tainted canvases
Remote images are governed by the browser’s same-origin and canvas security rules. An image loaded from another origin can taint the canvas, making the canvas unreadable for export. html2canvas cannot bypass that policy.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Rank #3
- Latest Digital Camera Built-in Fill Light : This compact digital camera is paired with a powerful CMOS processor and image stabilization to help you take & record the most exciting moments in 44 MP quality images & FHD 1080P quality videos anywhere, anytime. Plus, there is also a built-in fill light to help you take high quality pictures even in low light&dark settings, making this the perfect camera for all indoors/outdoors situations.
- Long-Lasting Battery Life & 16X Digital Zoom :This point and shoot camera will retain its battery charge even after long use. The controls and functions are easy to operate making this the perfect choice for children, teens and younger. This kids camera supports 16x digital zoom, you can zoom in or out the subject by pressing the W/T button for taking still photos to zoom in or out on distant objects and capture all the details you need.
- Multifunctional & Portable Digital Camera: This cheap digital camera is slim enough to fit in your pocket. You'll easily be able to take it with you on all your indoor/outdoor activities and adventures and ideal for beginners, children and teenagers. This kids digital camera is equipped with 20 filters, anti-shaking, self-timer, continuous shooting, date stamp, time-lapse recording, smile capture, internal MIC and speaker (recording sound videos), great for your daily photography needs.
- WEBCAM & PAUSE FUNCTION : More than just a FHD 1080p digital camera, it also works as a webcam for video calls and vlogging. Connect the camera to the computer, press shutter and power button at the same time and the camera will automatically turn on webcam mode for all your video calling and live streaming needs. The pause function allows you to pause when seeing playback videos.
- A Must Have Photography Device : This digital camera with SD card made from high-quality materials, this retro camera is safe and durable. Perfect for all ages to develop & improve their photographic abilities and observation skills. Our dedicated and experienced 24/7 support team is available for all after purchase troubleshooting, questions and technical help.
Use useCORS only when the image server allows it
If the remote server sends appropriate CORS response headers, request the image through CORS:
const canvas = await html2canvas(element, {
useCORS: true
});
This option does not grant permission by itself. The image host must permit the browser request. Check the image request in developer tools and confirm its response headers.
Use a proxy you control when CORS is unavailable
If the image server does not permit cross-origin use, route the asset through a suitable proxy that you control and configure it to return the required headers. Do not treat allowTaint: true as a solution: it can allow a tainted image into the rendering process, but it does not make a tainted canvas exportable with toDataURL.
Check every asset, not only the visible photo
A single remote background image, avatar, or CSS image can cause the export problem. Test the target with those assets removed, then inspect each external resource and its CORS response.
Free tools Windows power users keep installed
One-click scans. No signup required.
Useful capture patterns
Async/await in an existing workflow
Keep the Promise in the same flow that prepares the UI. This avoids capturing a partially updated element:
async function exportReport() {
const report = document.querySelector('#report');
if (!report) throw new Error('Report not found');
// Update application state here, then wait for your own data/render work.
const canvas = await html2canvas(report, {
scale: Math.min(window.devicePixelRatio, 2),
useCORS: true
});
const link = document.createElement('a');
link.download = 'report.png';
link.href = canvas.toDataURL('image/png');
link.click();
}
Download from a delegated click
If controls are inside the captured element, mark them with data-html2canvas-ignore so the exported image contains only the content users need to share.
Choose output dimensions deliberately
For a social card or receipt, set the element’s CSS dimensions first, then use scale for resolution. Do not enlarge an already huge page merely to obtain more pixels; the extra canvas memory can turn a successful capture into a blank or partial one.
html2canvas versus other ways to capture a page
The right method depends on whether you need a reconstructed element or a browser-faithful screenshot, where the code runs, and whether remote assets are authorized.
Rank #4
- 16MP Sensor: Captures detailed photos with a CMOS sensor for everyday shooting
- Optical Zoom: 5x optical zoom with a 28mm wide angle lens for flexible framing indoors or outdoors
- Full HD Video: Records 1080p video for travel clips, family moments, or simple vlogging
- Memory Support: Works with Class 10 SD, SDHC, or SDXC cards up to 512GB
- LCD Screen and Battery: 2.7in LCD screen and a rechargeable lithium-ion battery for on-the-go use
| Method | Best fit | Important trade-off |
|---|---|---|
| ScreenshotNeo | Website screenshots or PDFs through an API, including automated and AI-agent workflows | It loads the URL remotely; cookie banners, popups, and chat widgets are removed before capture, and only clean shots are billed. |
| html2canvas | Exporting one element directly in a user’s browser | DOM reconstruction, selective CSS support, CORS restrictions, and browser canvas limits apply. |
| Native browser-extension screenshot APIs | Capturing what the browser actually displays from an extension | They are a better fit than html2canvas when a true browser screenshot is required, but they require extension APIs. |
| Puppeteer or Playwright | Server-side or automated browser screenshots | They run a browser environment rather than the page’s existing client-side canvas. |
For screenshot APIs and services, ScreenshotNeo is the first alternative to try because it produces clean shots, bills only clean shots, and has the lowest paid plan.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
When you need a URL screenshot rather than an image of the current user’s DOM, ScreenshotNeo provides a single GET request. It can return PNG, JPEG, WebP, or PDF and supports full-page captures with lazy images loaded, element selection by CSS selector, dark mode, device presets or custom viewports, retina scale, custom CSS and JavaScript, clicks before capture, selector or network-idle waits, ad/tracker/request blocking, custom headers, cookies, user agents and Authorization, timezone and geolocation, transparent backgrounds, resizing, chosen cache TTLs, 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, which can simplify a migration.
Cookie banners, newsletter popups, and chat widgets are removed before the shot. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed; each response identifies the page verdict and billing status with X-Page-Verdict and X-Billed headers. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.
cURL
See the ScreenshotNeo documentation for request options. This call saves a WebP image:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
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));
Plans and limits
The Free plan includes 1,000 shots per month with no card. Paid plans are Starter ($5 for 3,000), Growth ($15 for 15,000), Pro ($39 for 60,000), Scale ($99 for 250,000), and Business ($249 for 1,000,000). Yearly billing gives two months free, and every feature is included on every plan. Create a free ScreenshotNeo account to start with 1,000 screenshots a month and no card.
Troubleshooting html2canvas exports
The export is blank or only part of the element
- Lower
scaleor reduce the target area to stay within the browser’s canvas limits. - For content beyond the viewport, set
windowWidthandwindowHeightto the element’s scroll dimensions. - Confirm that the selected element has dimensions and is rendered when the Promise starts.
Remote images disappear
- Inspect the image response for CORS permission.
- Set
useCORS: trueonly when the server permits the request. - Use a suitable proxy you control when it does not.
- Do not rely on
allowTaintto maketoDataURLwork.
The result does not match the page
- Compare the styles against html2canvas’s supported-features list.
- Simplify or adapt unsupported CSS for the export version of the component.
- Capture after fonts, data, class changes, and images needed by the design have rendered.
The browser becomes slow or crashes
- Capture a smaller element instead of the entire page.
- Use a lower scale, especially on high-density displays.
- Do not combine a very tall page, large width, and maximum device-pixel ratio.
You need a server-side screenshot
html2canvas depends on browser APIs and is not suitable for Node.js by itself. Use Puppeteer or Playwright for server-side browser rendering, or use a screenshot API when you want a URL-based service without maintaining browser infrastructure.
Reliability and cost considerations
Client-side html2canvas has no API charge, but it consumes the visitor’s CPU and memory and inherits that browser’s security policy, CSS implementation, and canvas limits. Test the same component on the browsers and device classes your users actually have. Keep exports bounded, handle Promise rejection, and provide a visible error state rather than silently offering a corrupt file.
An API approach moves rendering away from the user’s device and is appropriate for scheduled, server-side, or multi-URL work. With ScreenshotNeo, failed loads, bot checks, blank pages, timeouts, and cache hits are not billed, and the response headers tell your application which outcome occurred.
Recommended Free Tools
Frequently Asked Questions
Does html2canvas capture the whole browser window automatically?
No. Pass the specific DOM element you want to render. A full-page result may require a page-sized target and explicit window dimensions, and it remains subject to browser canvas limits.
Can I make an image from an element that uses a remote background image?
Only if that resource is available under the browser’s CORS rules or is served through a suitable proxy. A remote background can taint the canvas just like an external <img>.
What should I use when pixel-for-pixel browser fidelity is the requirement?
Use a native browser screenshot API, an automated browser such as Puppeteer or Playwright, or a URL screenshot service. html2canvas is intended for DOM-based reconstruction, so visual differences are possible.
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.

