Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

To capture dynamic content with html2canvas, wait until your application has rendered the exact state you want, select the rendered element, then await html2canvas and export its canvas. The key limitation: html2canvas reconstructs an image from DOM and CSS information; it does not take a pixel-for-pixel screenshot of the browser. Unsupported CSS, inaccessible images, and browser security rules can change or omit parts of the result.

What html2canvas captures—and what it does not

html2canvas runs in a browser and reads the DOM and styles to draw a representation of the page or an element onto a canvas. Its output depends on the CSS properties and resources it can read and render. It is therefore useful for exporting a UI component, report, or card, but it is not equivalent to capturing the browser’s already-rendered pixels. The project documentation describes its rendering approach and supported features at html2canvas documentation.

That distinction matters when the result must exactly match a browser view. CSS features outside the library’s supported set may look different or be absent, and cross-origin content remains subject to browser security. For a true browser screenshot or server-side capture, the project FAQ points to browser extension screenshot APIs or browser automation tools such as Puppeteer and Playwright instead: html2canvas FAQ.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Capture the intended dynamic state

html2canvas returns a Promise, but it cannot know when your application considers its asynchronous work complete. Start capture only after data fetching, state updates, and rendering have reached the state you want. Also make relevant images and fonts ready if they are part of the output. Use your framework’s completion flow, a data-loading promise, or an application event—not an arbitrary sleep that may be too short on a slow device.

#1 Best Overall
Lexar D40E 128GB Dual USB 3.2 Gen 1 Type-C Jump Drive, Champagne Silver
  • 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

Example: wait for application work, select an element, export PNG

The following browser-side pattern assumes renderReport() is an application function that resolves after the report data is available and the UI update has been committed. Adapt that readiness signal to your app. Install html2canvas in your project as documented by the library, and ensure #report exists before running this code.

async function captureReport() {
  await renderReport(); // Your app's data/render completion signal.

  const target = document.querySelector("#report");
  if (!target) {
    throw new Error("Could not find #report");
  }

  const canvas = await html2canvas(target, {
    onclone(clonedDocument) {
      clonedDocument.querySelector(".capture-controls")?.remove();
    },
    useCORS: true,
  });

  const blob = await new Promise((resolve) =>
    canvas.toBlob(resolve, "image/png")
  );
  if (!blob) {
    throw new Error("Canvas could not be exported as PNG");
  }

  const link = document.createElement("a");
  link.download = "report.png";
  link.href = URL.createObjectURL(blob);
  link.click();
  URL.revokeObjectURL(link.href);
}

captureReport().catch(console.error);

html2canvas(target, options) resolves to a canvas; awaiting it ensures you export only after rendering has completed. toBlob() produces a PNG blob for download or upload. If your app updates the DOM without an awaitable render function, trigger capture from the framework’s post-render lifecycle or the event that confirms the target content is ready. The exact signal is application-specific.

Wait for images that affect the capture

If images are inserted dynamically, make sure they have loaded before capturing. For a known set of same-origin images, your app can await each image’s decode() promise or its load/error event. A remote image additionally needs permission for canvas use; waiting for it to load alone does not remove cross-origin restrictions. Fonts can also affect layout, so wait for the document’s font readiness when web fonts are material to the result.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Capture a particular region

Pass the element returned by querySelector(), rather than the whole document, when you need only a component or section. Confirm the selector matches the intended element after the dynamic update. html2canvas also documents crop-related options for controlling the rendered region; use the configuration reference for the precise option names and behavior: configuration options.

Rank #2
KOOTION USB C Flash Drive 32GB 2 in 1 OTG USB 3.0/Type C Thumb Drive Dual Drive USB C Memory Stick for Smartphone Laptop Tablet PC, Blue
  • 2 in 1: USB C + USB 3.0, 32GB usb c flash drive has dual ports, usb 3.0 port is applied to all devices which have usb 3.0 interface and usb c port is widely used in all Android smartphones with OTG function
  • High Speed USB 3.0: Read speed up to 90 MB/s, Write speed up to 30 MB/s, the speed of USB 3.0 interface is faster than USB 2.0, save time to wait, increases work productivity. Note: Speed will be limited if you use the USB key in the USB 2.0 interface
  • Large Compatibility: The USB 3.0 Connector is compatible with USB 3.0 & USB 2.0 backward USB 1.1 devices, such as Laptop, Desktop, Car Audio, Tablet, TV, Speakers, Projector. USB-C port is compatible with all Android Smartphones
  • Expand Storage: Good performance in storing, transferring and sharing digital data with families, friends, colleagues, customers. It can expand the capacity of smartphone, you can watch movies or share pictures when you go on vacation with your family
  • Note: Make sure your smartphone is equipped with OTG function and need to open OTG function in Settings when you plug memory stick, then you can transfer easily data bewteen different devices

Prepare a clean capture with configuration options

Configuration can adjust the cloned page, resource handling, viewport, and output scale. Check the current configuration page before relying on defaults, since options and browser behavior can change.

Option or technique What it does When to use it
onclone Runs against the cloned document used for rendering; edits there do not alter the original document. Remove controls, overlays, animation artifacts, or other transient UI just for the export.
data-html2canvas-ignore Marks elements to exclude from rendering. Identify elements that should never appear in a capture.
useCORS Attempts CORS-based loading for cross-origin images. Use when the remote asset server explicitly permits the request.
proxy Uses a configured proxy for remote resources. Consider when you control a trusted proxy that can retrieve the needed assets.
scale Controls rendering scale; the default is based on device pixel ratio. Lower it to reduce output dimensions and memory use, or raise it when higher-resolution output is needed and the canvas remains manageable.
width and height Control the rendered dimensions. Use to fit the required capture bounds; verify the result is not clipped.
windowWidth and windowHeight Set the rendering viewport and can affect media queries and layout. Match the intended viewport; for some large captures, matching scroll dimensions can help with clipping.

For capture-only styling, use onclone to adjust the cloned DOM or styles rather than temporarily mutating the live page. This keeps the visible application state intact while preparing a cleaner export. Do not assume that clone-side style changes can make an unsupported CSS feature render correctly; simplify or replace the relevant styling if the renderer does not support it.

Cross-origin images, iframes, and browser security

Canvas security is a common source of missing content and failed exports. A browser restricts reading pixel data from resources that do not grant the necessary cross-origin permission. html2canvas cannot bypass that restriction.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Remote images

Set useCORS: true to attempt a CORS-enabled image load, but the image host must return suitable CORS permission. If it does not, the image may be omitted or the canvas may become unusable for export. A configured proxy is another documented approach, provided the proxy is trusted and correctly handles the resource. Avoid routing private or authenticated content through a proxy you do not control.

Rank #3
Lexar D40E 64GB Dual USB 3.2 Gen 1 Type-C Jump Drive, Champagne Silver
  • 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

allowTaint is not a workaround for export security: allowing a tainted canvas does not make its pixel data exportable. The FAQ explains why remote assets are skipped by default and the consequences for canvas export.

Frames and embedded content

Same-origin iframe content can be traversed recursively. Cross-origin iframe contents are inaccessible to the page’s script, and a sandboxed frame without allow-same-origin is also restricted. If an embedded view is missing, capture its content from within the permitted origin or use a capture method with access to the rendered browser surface.

Output size, fidelity, and performance

Canvas dimensions consume memory, and browsers impose platform-dependent limits. There is no single safe maximum that applies across browsers and devices. Very large outputs can be blank, partial, or fail without a useful exception. Reduce the capture dimensions or scale, and capture a smaller element or split a long page where appropriate. Check the generated canvas dimensions and the actual exported file rather than assuming a successful Promise means every pixel rendered as intended.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Higher scale increases pixel dimensions and memory demand. Because scale defaults to device pixel ratio, the same CSS-sized element can produce different output dimensions on devices with different pixel ratios. Specify a deliberate scale when consistent output size matters, then test it on the browsers and devices you support.

Rank #4
2-Pack 128GB USB C Flash Drive Dual Type C + USB A Memory Stick Jump Drive 2-in-1 Thumb Drive for Storage and Backup (128GB*2 Black&Blue)
  • 2-in-1 Dual Design: Features both USB-C and USB-A connectors, making it compatible with phones, tablets, MacBooks, PCs, and laptops-no adapter needed
  • Wide Compatibility: Works seamlessly with USB A and USB C devices, ensuring reliable file transfers across smartphones, computers, and more
  • Ample Storage Options: Available in 16GB/32GB/64GB/128GB providing plenty of space for photos, videos, music, and documents
  • Portable & Lightweight: Compact and durable design for travel, school, or daily use-take your files anywhere
  • Plug-and-Play Convenience: No software or drivers required; simply insert into USB-C or USB-A ports and start transferring files instantly

Viewport values also affect layout. windowWidth and windowHeight can change media-query outcomes, so setting them merely to enlarge a capture may cause the page to render differently from the visible viewport. For clipping in large-element captures, the FAQ suggests matching these values to scroll dimensions in some cases; treat that as a troubleshooting option, not a universal fix.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting common capture failures

Symptom Likely cause What to check or change
New data or UI is missing Capture started before the app committed its dynamic update, or the selector matched the wrong element. Connect capture to the app’s completion signal, then verify the target selector and wait for important resources.
Remote image is absent The resource server did not authorize CORS, or the image was not ready at capture time. Wait for the image; confirm the server’s CORS response; try useCORS only when the host grants access, or use a trusted configured proxy.
PNG export fails after rendering The canvas may be tainted by a cross-origin resource. Resolve the asset’s CORS access or proxy setup. allowTaint does not make a tainted canvas exportable.
Iframe content is missing The frame is cross-origin or sandboxed without same-origin access. Capture the content from within its permitted origin or choose a method that captures browser-rendered pixels.
CSS differs from the page The library does not implement every browser CSS feature. Check the supported features in the documentation; simplify or adjust capture-only styling in onclone.
Canvas is blank, partial, or clipped Dimensions may exceed browser/platform limits or viewport and scroll dimensions may not align. Inspect width, height, scroll dimensions, viewport options, and scale. Reduce output size; test the relevant browser/device combination.
Code fails in Node.js html2canvas relies on browser APIs and is not suitable for direct Node.js rendering. Run it in a browser, or use browser automation such as Puppeteer or Playwright for server-side screenshot generation.

When to choose a different capture method

Use html2canvas when client-side code should render a selected DOM region and the library’s supported CSS and resource access meet your needs. Choose a different approach when the requirement is a true screenshot of browser pixels, a server-side capture, or reliable handling of content inaccessible to the page’s JavaScript. The html2canvas documentation identifies browser extension screenshot APIs for extension contexts and Puppeteer or Playwright for server-side browser automation. Compare options by capture fidelity, CSS and embedded-content support, cross-origin requirements, execution environment, and output-size behavior.

Or skip the browser setup

If you need a screenshot of a website URL rather than a client-side DOM-to-canvas export, ScreenshotNeo provides a website screenshot API and MCP server. Its GET endpoint returns an image or PDF; the example below saves a WebP response. See the ScreenshotNeo API documentation for parameters and response details.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo accepts cookie and consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf 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. Every feature is available on every plan.

Sign up free for 1,000 screenshots a month with no card.

Best Value
Samsung Type-C USB Flash Drive 256GB, USB 3.2 Gen 1, Up to 400MB/s
  • USB-C STORAGE ON THE GO: This sleek drive is supported by Samsung NAND flash and is incredibly compact to fit in the palm of your hand; Count on reliable performance and fast transfer speeds while staying compact
  • PERFORMANCE WITH SPEED: No need to choose between performance and reliability; Experience a fast, powerful flash drive that transfers 4GB files in just 11 seconds with up to 400MB/s USB 3.2 Gen 1 read speeds and is backward compatible with USB 3.0/2.0
  • MODERN MEETS ICONIC: The ultra-sleek USB-C drive looks as good as it performs; Featuring a reversible plug, the Type-C inserts into your devices seamlessly every time; Transfer large files with style and ease
  • ALWAYS CONNECTED: USB-C is compatible across devices, including laptops, tablets, phones and cameras, with enough space for 63,730 photos or maximum 12 hours of 4K video; With up to 256GB of storage space, this pocket-sized thumb drive comes in handy wherever you go
  • TOUGH & TRUSTED: Files stay secure, no matter the terrain; Samsung's flash memory technology makes the Type-C a trustworthy drive to store your valuable data; It's waterproof, shock-proof, magnet-proof, temperature-proof, and X-ray-proof body, plus it's backed by a 5-year limited warranty

Frequently Asked Questions

Can html2canvas capture content that appears after a fetch request?

Yes, if you call it after your application has completed the fetch-driven update and rendered the intended state. html2canvas does not detect application readiness for you.

Does useCORS let html2canvas read every remote image?

No. The remote server must grant the required CORS permission; the option cannot override browser security.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Can I use html2canvas directly in Node.js?

No. It depends on browser APIs. For server-side browser screenshots, the project FAQ points to Puppeteer or Playwright.

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.