Skip to content
SnapDOMTry SnapStudioGitHub★ 8K
Library Comparisons

HTML-to-Image JavaScript Libraries

Compare the libraries that turn a rendered DOM element into an image: html2canvas, html-to-image, dom-to-image, modern-screenshot and SnapDOM. Rendering approaches, output contracts and examples.

Last updated: October 2026 · maintained by the SnapDOM team.

Which to use

  • Capture in the user's browser: SnapDOM. Measure it in the live benchmark, check pixel fidelity, add PDF, vector or HTML through plugins.
  • Already on html2canvas, html-to-image or dom-to-image: run the failing component in the live lab, then use the migration table on its head-to-head page.
  • Rendering without a user's browser: Puppeteer, Playwright or a hosted service.

Three ways to turn HTML into an image

Pick the environment first, then compare output and performance:

  • Client-side libraries (SnapDOM, html2canvas, html-to-image, dom-to-image, modern-screenshot) run in the user's browser. No DOM goes to a screenshot server; fonts and images may still need network requests.
  • Server-side browser automation (Puppeteer, Playwright) runs a controlled browser in your infrastructure, for automated navigation, testing and rendering jobs.
  • Hosted APIs (HCTI, Urlbox, and similar) take HTML or a URL and return an image. Pricing and limits vary.

The rest of this page covers the client-side libraries, where the differences are subtle.

Run the benchmark Compare capture libraries on real-world scenes in your browser, with pixel checks for specific fixtures.

Feature matrix

LibraryApproachShadow DOMWeb fontsPseudo-elementsPerformanceRelease statusNo server
SnapDOMforeignObjectYesYesYesBenchmarkSee releasesYes
html2canvasJS re-paintPasses tested fixturePartialPasses tested fixtureBenchmarkSee releasesYes
html-to-imageforeignObjectOpen rootsYesYesBenchmarkSee releasesYes
modern-screenshotforeignObjectOpen rootsYesYesBenchmarkSee releasesYes
dom-to-imageforeignObjectNoPartialPasses tested fixtureBenchmarkSee releasesYes
Puppeteer / PlaywrightBrowser automationYesYesYesBenchmarkSee releasesServer

Support varies by fixture and rendering mode; test your own UI. The live benchmark reports on its own fixtures and loaded versions.

Head-to-head deep dives

The libraries, reviewed

SnapDOM

Fast, faithful, extensible. Clones the styled DOM and renders it inside an SVG <foreignObject>, so the browser paints the result. Core exports: SVG, PNG, JPG, WebP, Canvas and Blob. Official plugins add HTML, structured context and maps, searchable PDF, editable vector, GIF and video. Browser security still blocks inaccessible resources and tainted canvas pixels.

html2canvas

Canvas rendering from the DOM. html2canvas implements a CSS painter in JavaScript. Check its supported properties against your page.

html-to-image

A dom-to-image fork. html-to-image uses SVG foreignObject and returns data URLs, Canvas and Blob. Font options and return types differ from SnapDOM's.

modern-screenshot

A TypeScript capture library. modern-screenshot uses SVG foreignObject and shares SnapDOM's core image, Canvas and Blob formats. SnapDOM's plugin lifecycle adds other outputs and transformations.

dom-to-image

The original API behind several forks. dom-to-image captures a node through SVG foreignObject. Migration touches return types, font handling and inclusion predicates.

Server-side & hosted options

For capture without the user's browser, navigation workflows or scheduled rendering. A pinned browser version makes output repeatable; different engines are still not byte-identical.

FAQ

What is the best HTML-to-image library in 2026?

Depends on environment, output type and content. SnapDOM covers browser-side capture with optional plugin exports. Browser automation suits server jobs and controlled test environments.

Is there a maintained html2canvas alternative?

SnapDOM, html-to-image and modern-screenshot, all based on SVG foreignObject. Check their release histories and test what fails in your current integration.

Why does my capture miss web fonts or Shadow DOM?

Check font readiness, resource access and how the library handles shadow roots. SnapDOM v3 embeds used web fonts by default and walks open roots. Closed roots and inaccessible font files remain limitations.

Can I convert HTML to an image without a server?

Yes. Client-side capture needs no screenshot server, though fonts and images may still be fetched. Server automation is for capture outside a user session.