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.

Use html2canvas in a browser to render a text element into a canvas, then export that canvas with the Canvas API. The essential sequence is: wait for the text and fonts to finish loading, select the element, call html2canvas(element, options), and download the returned canvas as PNG with toDataURL() or toBlob(). html2canvas reconstructs the element from its DOM and CSS; it is not a native browser screenshot and remains subject to browser security rules.

What html2canvas actually does

html2canvas traverses an element’s DOM, reads its computed styles, and paints a representation into a new <canvas>. Its promise resolves to that canvas. The approach is useful for text cards, quotes, invoices, labels, social graphics, and other content already rendered in a web page. It does not capture the browser’s final pixels in the same way as a native screenshot API, so unsupported CSS, plugins, inaccessible external content, and browser rendering differences can change the result.

The library runs in modern evergreen browsers and depends on browser APIs. It is not a Node.js renderer. Install the maintained package in a browser application:

npm install @html2canvas/html2canvas

Then import it from your client-side JavaScript bundle.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • 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

Minimal working example: render a text element

Give the content a stable selector and wait until it is visible in the viewport:

<div id="text-to-capture" class="card">
  <h1>A shareable text card</h1>
  <p>This paragraph will become a PNG.</p>
</div>
<button id="save" type="button">Download PNG</button>

<script type="module" src="/app.js"></script>
import html2canvas from '@html2canvas/html2canvas';

const element = document.querySelector('#text-to-capture');
const button = document.querySelector('#save');

button.addEventListener('click', async () => {
  if (!element) throw new Error('Capture element was not found');

  // Ensure web fonts used by the card have settled before layout is read.
  await document.fonts.ready;

  const canvas = await html2canvas(element, {
    backgroundColor: '#ffffff',
    scale: window.devicePixelRatio,
  });

  document.body.appendChild(canvas); // optional preview of the result

  const link = document.createElement('a');
  link.download = 'text.png';
  link.href = canvas.toDataURL('image/png');
  link.click();
});

document.fonts.ready is a practical readiness check, not a guaranteed application-specific loading policy. If your page loads content or images asynchronously, wait for those operations too. A fallback font can change glyph widths and line breaks if capture starts too early.

Download PNG, JPEG, or a Blob

PNG download

html2canvas returns a canvas; downloading is a separate Canvas API operation. The anchor method above creates a PNG data URL and clicks it after rendering completes. Choose a filename that reflects the content or record identifier.

Blob output for uploads

Use toBlob() when you need a file for an upload, object URL, or other file-processing pipeline. It avoids putting the entire encoded image in a data URL string.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const canvas = await html2canvas(element, { backgroundColor: '#fff' });

const blob = await new Promise((resolve, reject) => {
  canvas.toBlob(result => result ? resolve(result) : reject(new Error('PNG encoding failed')), 'image/png');
});

const file = new File([blob], 'text.png', { type: 'image/png' });
const form = new FormData();
form.append('image', file);
await fetch('/upload', { method: 'POST', body: form });

Other image formats

Pass an image MIME type to the Canvas API when your workflow permits it:

const jpegUrl = canvas.toDataURL('image/jpeg', 0.92);
const webpUrl = canvas.toDataURL('image/webp', 0.90);

JPEG has no transparency and may soften small text; PNG is usually the safer default for typography and flat-color cards.

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • 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

Options that control text quality and layout

scale: output density

scale controls the number of output pixels per CSS pixel. It defaults to window.devicePixelRatio. Set it deliberately when you need predictable dimensions:

const canvas = await html2canvas(element, {
  scale: 2,
  backgroundColor: '#ffffff'
});

A larger scale generally makes text sharper on high-density displays, but increases memory use, encoding time, and the chance of hitting browser canvas-size limits. It does not repair a font that loaded incorrectly or CSS that html2canvas cannot reproduce.

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

backgroundColor: opaque or transparent

The default background is #ffffff. Set backgroundColor: null for transparency:

const transparentCanvas = await html2canvas(element, {
  backgroundColor: null,
  scale: 2
});

Crop with x, y, width, and height

These options render a specific rectangle instead of the whole element. Values are CSS-pixel coordinates in the capture context.

const cropped = await html2canvas(element, {
  x: 16,
  y: 24,
  width: 640,
  height: 360
});

Control responsive layout with viewport options

windowWidth and windowHeight define the viewport used for layout and media queries. They matter when the same text wraps differently at mobile and desktop widths.

const desktopCard = await html2canvas(element, {
  windowWidth: 1440,
  windowHeight: 900,
  scale: 2
});

For a long text block, use its measured dimensions where appropriate:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • 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 width = element.scrollWidth;
const height = element.scrollHeight;
const longCanvas = await html2canvas(element, {
  windowWidth: width,
  windowHeight: height,
  width,
  height,
  scale: 1
});

Very large canvases are limited by the browser and device. Split long content into pages or sections if the render fails or consumes excessive memory.

scrollX and scrollY

Set scroll positions when fixed-position elements or a particular scroll state affect the intended composition:

const canvas = await html2canvas(element, {
  scrollX: window.scrollX,
  scrollY: window.scrollY
});

Exclude controls with data-html2canvas-ignore

Add the attribute to buttons, handles, editing tools, or other UI that should not appear:

<button data-html2canvas-ignore>Delete</button>

The marked node is omitted from the reconstructed image.

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

Report resource failures with onError

const canvas = await html2canvas(element, {
  onError(error) {
    console.error('html2canvas resource error', error);
  }
});

Fonts, images, and capture timing

Capture only after the text has reached its final state. Await application data, make sure the element is displayed, and wait for custom fonts:

await document.fonts.ready;

const images = [...element.querySelectorAll('img')];
await Promise.all(images.map(img => {
  if (img.complete) return Promise.resolve();
  return new Promise(resolve => {
    img.addEventListener('load', resolve, { once: true });
    img.addEventListener('error', resolve, { once: true });
  });
}));

const canvas = await html2canvas(element);

Waiting for an image’s load event does not bypass cross-origin restrictions. It only ensures the resource has finished loading before the renderer reads the page.

Rank #4
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • 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

Cross-origin images and canvas security

Images from another origin can taint the canvas. Once tainted, export operations such as toDataURL() are blocked by the browser. Use useCORS: true only when the image server sends suitable CORS headers:

const canvas = await html2canvas(element, {
  useCORS: true
});

If the server cannot provide CORS headers, route the image through a same-origin proxy configured with html2canvas’s proxy option. The proxy must fetch the resource and return it with a response your page is allowed to use. Setting allowTaint does not make a tainted canvas exportable; it can permit drawing but cannot remove the browser’s security restriction.

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.

Iframes

Cross-origin iframes cannot be rendered because the browser does not expose their contentDocument. Same-origin iframes can be supported recursively. If an embedded frame belongs to another origin, capture content through that service’s own page or arrange a same-origin architecture instead of expecting html2canvas to read it.

Why the result differs from the page

  • Unsupported CSS: html2canvas may not reproduce every CSS property exactly.
  • External content: inaccessible images, fonts, SVGs, and frames can be missing or prevent export.
  • Plugins and browser features: content painted by plugins is outside the DOM/CSS model.
  • Timing: fallback fonts, animations, lazy images, or late data can change the captured layout.
  • Canvas limits: a high scale multiplied by a large element can exceed device or browser limits.

For a DOM-based text card, these trade-offs are often acceptable. A native browser screenshot or server-side browser renderer is a better fit when exact painted pixels, authenticated browser state, or broad CSS coverage is more important than running entirely in the user’s browser.

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

Troubleshooting checklist

The selector is null or the image is blank

  • Check the selector in the browser console and confirm it returns the intended node.
  • Call html2canvas after the component has mounted and after content has been inserted.
  • Make sure the node is not display: none, detached, or outside the relevant capture viewport.

Text is blurry

  • Increase scale, commonly to window.devicePixelRatio or a deliberate value such as 2.
  • Do not enlarge a small canvas with CSS; render more pixels instead.
  • Wait for document.fonts.ready so fallback glyphs do not become the captured layout.
  • Check the final canvas dimensions and reduce scale if memory pressure causes an incomplete render.

Images or SVGs are missing

  • Wait for image loading and add useCORS: true only when the origin returns compatible CORS headers.
  • Use a same-origin proxy for assets that cannot provide CORS.
  • Inspect onError output for the failed resource.

toDataURL throws a security error

The canvas is probably tainted by a cross-origin image. Fix the image’s CORS response or proxy it through your origin. allowTaint is not an export workaround.

The bottom of a long text block is cut off

Measure scrollWidth and scrollHeight, provide suitable width, height, windowWidth, and windowHeight, and check browser canvas limits. For very long documents, capture separate sections rather than one enormous bitmap.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【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.

Responsive wrapping is wrong

Set windowWidth to the target layout width and ensure the element’s styles use the intended media-query breakpoint. A capture made at the current narrow viewport will legitimately wrap differently from a desktop design.

Animations produce inconsistent captures

Pause animations or add a capture-only class that sets stable transition and animation values. Trigger the capture after the desired visual state is applied.

Performance and reliability decisions

Rendering cost grows with the element’s pixel area and scale. Keep capture regions no larger than necessary, avoid repeatedly rendering the same unchanged card, and release object URLs when using toBlob(). For high-volume or long-running jobs, perform work in a controlled browser environment rather than blocking the main interface.

html2canvas is appropriate when JavaScript state in the current page matters and the target is a DOM element. A native browser screenshot is preferable when pixel fidelity and cross-origin browser behavior are priorities. A server-side renderer is preferable when captures must run without a user’s browser, be queued, or be generated consistently for many URLs. The official html2canvas material does not publish a quantitative benchmark comparing these approaches, so choose from their capabilities rather than an invented speed or accuracy figure.

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

Or skip the browser setup

If you need a URL screenshot rather than a DOM element rendered inside your own page, ScreenshotNeo provides a single-request website screenshot API. It can capture PNG, JPEG, WebP, or PDF and includes controls for full-page lazy-image loading, CSS-selector element capture, device and viewport settings, retina scale, custom CSS and JavaScript, clicks, waits, blocking, headers, cookies, user agents, timezone, geolocation, transparent backgrounds, resizing, caching, signed links, asynchronous webhooks, and bulk capture of up to 100 URLs per call.

cURL:

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)
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}`);

See the ScreenshotNeo API documentation for parameters and response headers. Cookie banners, newsletter popups, and chat widgets are removed before the shot. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and the response identifies the page verdict and billing result. An MCP server lets AI agents use take_screenshot, get_page_info, and capture_pdf. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.

FAQ

Can html2canvas capture text selected by the user?

Yes, if the selected text is inside a visible DOM element you pass to html2canvas. Selection highlighting itself may not be reproduced consistently, so style a dedicated capture state when that appearance matters.

Does html2canvas work in Node.js?

No. It depends on browser APIs. Use it in a browser, or use a browser-based server renderer for a server-only workflow.

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

Is a PNG automatically saved when the promise resolves?

No. The promise returns a canvas. You must encode it with toDataURL() or toBlob() and then save or upload the result.

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.