What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Use html2canvas to render a selected <div> into a canvas, then export that canvas as a PNG. In jQuery, select the element with $('#capture')[0]; in vanilla JavaScript, use document.querySelector('#capture'). Both approaches run in the browser and reconstruct the DOM rather than capturing the browser compositor pixel-for-pixel, so CSS support and visual fidelity are not absolute.
What “convert a div to an image” actually means
HTML has no built-in div.toImage() method. A library such as html2canvas reads the target element, its styles and its child content, then paints a representation into an HTML <canvas>. The library describes this as taking “screenshots” directly in the user’s browser, but its documentation also explains that it is not a literal screenshot and that some CSS properties are unsupported.
The result is a canvas bitmap. You can append that canvas as a preview, call toDataURL() to create an image URL, or trigger a download. The method is suitable for an interactive webpage where the user clicks a button. It is not the right primitive for server-side rendering, browser extensions or guaranteed compositor-level fidelity.
Vanilla JavaScript: complete PNG download
Include html2canvas, mark up the element, and wait for the returned Promise before exporting:
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 →#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
<div id="capture" style="padding:16px; background:#f5da55">
<h2>Hello</h2>
<p>This content will be captured.</p>
</div>
<button id="download" type="button">Download PNG</button>
<script src="https://html2canvas.github.io/html2canvas/dist/html2canvas.min.js"></script>
<script>
document.querySelector('#download').addEventListener('click', async () => {
const element = document.querySelector('#capture');
if (!element) return;
const canvas = await html2canvas(element);
const link = document.createElement('a');
link.download = 'capture.png';
link.href = canvas.toDataURL('image/png');
link.click();
});
</script>
The important sequence is: obtain the actual DOM node, call html2canvas(element), await the Promise, and pass the resulting canvas to toDataURL('image/png'). The anchor’s download attribute supplies the filename. For a preview instead of a download, use document.body.appendChild(canvas) or append it to a dedicated preview container.
Capture after the content is ready
Images, web fonts and asynchronously rendered components must be ready before capture. Attach the handler after the page has loaded, or wait for the specific application state that should appear in the image. If a framework updates the div, capture after its update has painted rather than immediately after changing state.
jQuery version
jQuery can select the element, but html2canvas expects a DOM element, not a jQuery collection. Pass the first item with [0]:
<div id="capture">
<h2>Invoice preview</h2>
<p>This section becomes a PNG.</p>
</div>
<button id="download" type="button">Download PNG</button>
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script src="https://html2canvas.github.io/html2canvas/dist/html2canvas.min.js"></script>
<script>
$('#download').on('click', async function () {
const element = $('#capture')[0];
if (!element) return;
const canvas = await html2canvas(element);
const link = document.createElement('a');
link.download = 'capture.png';
link.href = canvas.toDataURL('image/png');
link.click();
});
</script>
There is no separate jQuery adapter documented by html2canvas. jQuery handles selection and events; html2canvas handles rendering of the underlying node.
Control the output
Resolution and device-pixel ratio
html2canvas’s scale option controls the bitmap density and defaults to window.devicePixelRatio. A larger value produces a sharper, larger image but consumes more memory:
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
const canvas = await html2canvas(element, {
scale: window.devicePixelRatio,
backgroundColor: '#ffffff'
});
Use a fixed scale such as 1 for predictable file dimensions, or a higher value for print-like output after testing the largest target element. A transparent background can be requested with backgroundColor: null when the rendered content and your downstream format support transparency.
Crop, dimensions and long content
The configuration supports width, height, x and y for sizing and cropping. For a div that extends beyond the viewport, provide its scroll dimensions so the clone has enough layout space:
const canvas = await html2canvas(element, {
windowWidth: element.scrollWidth,
windowHeight: element.scrollHeight,
width: element.scrollWidth,
height: element.scrollHeight
});
Very tall or wide canvases can exceed a browser or platform limit. The documented failure mode is often a blank or partially rendered canvas without an exception. Split long content into sections, reduce scale, or offer separate pages, then inspect the output on the browsers and devices you support.
Recommended Free Tools
Exclude controls and alter the clone
Add data-html2canvas-ignore to content that should not appear, or use ignoreElements:
const canvas = await html2canvas(element, {
ignoreElements: node => node.matches('.no-print, button')
});
Use onclone to change only the cloned document, leaving the live page untouched. This is useful for removing animations, expanding a collapsed section or applying capture-only styles:
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.
const canvas = await html2canvas(element, {
onclone: clonedDocument => {
clonedDocument.querySelectorAll('.animated').forEach(node => {
node.style.animation = 'none';
node.style.transition = 'none';
});
},
onError: error => console.error('Resource failed during capture', error)
});
Other documented options include viewport dimensions, crop coordinates, a background color, CORS and proxy settings, and an error callback. Keep the capture-specific CSS explicit so a responsive breakpoint does not unexpectedly change the image.
Why aren’t my images rendered?
Images loaded from another origin can taint the canvas. Once tainted, browser security rules prevent reading it with toDataURL(). Setting useCORS: true helps only when the image server sends an appropriate Access-Control-Allow-Origin header:
const canvas = await html2canvas(element, {
useCORS: true
});
If you control neither server nor headers, fetch the resource through a same-origin proxy that you operate and configure the documented proxy option. Do not treat allowTaint: true as an export fix; allowing taint does not make a tainted canvas readable. Check image URLs, redirects, credentials and response headers in the browser’s network panel.
Why does CSS render incorrectly or only partially?
html2canvas implements its own DOM and CSS rendering model. Unsupported or partially supported properties, filters, complex blend modes, unusual pseudo-elements, video and browser-specific effects may differ from the live page. The project’s behavior documentation explicitly says that not all CSS properties work.
- Replace an effect with a capture-only solid color, border or shadow in
onclone. - Freeze transitions and animations before calling html2canvas.
- Wait for web fonts and images, then capture again.
- Test SVG, masks, transforms and custom fonts on every browser that matters to your product.
For a design that must match the compositor exactly, use a real browser screenshot rather than a DOM reconstruction.
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
Why is the produced canvas empty or cut off halfway?
First inspect the element’s computed size and scrollWidth/scrollHeight. An element that is hidden, has zero dimensions, is clipped by a parent, or is captured before layout completes can produce an empty result. For long content, pass adequate windowWidth and windowHeight, lower scale, or split the capture. Canvas limits vary by browser and platform, so there is no single safe maximum that applies everywhere.
PC 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 & 11Outdated 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 matchAlso check for cross-origin resources: a security failure may occur at export even when the canvas appears visually populated. Log the Promise rejection and the onError callback rather than silently downloading a broken file.
Iframes and security boundaries
Same-origin iframes can be rendered recursively. Cross-origin frames cannot be read because browser security prevents access to their contentDocument; a sandboxed frame without allow-same-origin has the same limitation. Capture the framed application from its own page, change the embedding policy where you control both origins, or use a real browser automation workflow with appropriate authorization.
Download, preview and format decisions
The documented examples demonstrate PNG export:
const pngUrl = canvas.toDataURL('image/png');
PNG preserves sharp text and transparency. The supplied html2canvas examples establish PNG, not a tested JPEG workflow; if you choose another canvas export format, verify browser behavior, quality settings and transparency requirements for your target browsers. Data URLs for very large images consume memory. For larger workflows, keep the canvas in memory only as long as needed, release references after upload, and consider a server-side pipeline.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.When html2canvas is the wrong tool
| Need | Better fit | Reason |
|---|---|---|
| Interactive capture inside a normal webpage | html2canvas | Runs in the page and returns a canvas Promise. |
| Pixel-faithful page or element screenshot on a server | Puppeteer or Playwright | html2canvas’s FAQ points to real browser automation for server-side generation. |
| Browser extension tab capture | Native tab-capture APIs | The FAQ recommends browser-native capture rather than html2canvas. |
| Cross-origin iframe or asset you cannot authorize | Permissioned proxy or real browser workflow | Client-side JavaScript cannot bypass the same-origin policy. |
Server-side html2canvas is not supported: the project says it relies on browser APIs and is unsuitable for Node.js. A browser automation service can also wait for network idle, set a viewport and capture the compositor output, but it introduces browser setup and operational costs.
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.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server when you need a URL captured outside your page. One GET request returns PNG, JPEG, WebP or PDF. Before capture it accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups and chat widgets; each cleanup step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing status.
For a URL-based capture, see the ScreenshotNeo API documentation:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Its server supports full-page lazy-image loading, CSS-selector element capture, dark mode, device presets or custom viewports, retina scale, PDF paper and page controls, custom JavaScript and CSS, clicks, selector waits, delays, network-idle waits, request blocking, headers, cookies, user agents, authorization, timezone and geolocation, transparent backgrounds, resizing, TTL caching, signed image links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, usage reporting and an OpenAPI specification. Parameter names used by other screenshot APIs also work, which can simplify migration.
An 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 shots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account to try the URL workflow.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsTroubleshooting checklist
- “html2canvas is not defined”: load the library before your script and check the network request for the script.
- Nothing downloads: verify that the selected node exists, the click is user initiated, and the canvas has nonzero dimensions.
- SecurityError on
toDataURL: fix image CORS headers or use a same-origin proxy. - Fonts or images missing: wait for them to load and capture after the final layout.
- Half an element is missing: account for scroll dimensions and parent overflow; reduce scale for very large output.
- Styles differ: identify unsupported CSS, freeze animation and provide capture-only styles through
onclone. - Cross-origin iframe is blank: browser policy prevents access; same-origin it, obtain permission, or capture through an authorized browser workflow.
Frequently Asked Questions
Can I convert a div without installing a library?
Not with a standard built-in DOM method. You can draw selected content manually on a canvas, but reproducing arbitrary HTML and CSS is why libraries such as html2canvas are commonly used.
Does html2canvas create a real screenshot?
No. It reconstructs the selected DOM in a canvas. A real browser screenshot from Puppeteer, Playwright or a capture service is preferable when compositor-level pixel fidelity is required.
Can html2canvas run in Node.js?
The project FAQ says it is browser-based and not suitable for Node.js. Use a real browser automation tool or a screenshot API for server-side work.
Why does my jQuery object fail as the argument?
html2canvas documents a DOM element argument. Convert the jQuery collection to its first underlying node with $('#capture')[0].
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.




