html-to-image

Turns any DOM node into a PNG, JPEG, SVG, or canvas image entirely client-side, with no server or screenshot service required.

Library
npm
v1.11.13
7,230stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
55/100Fair
Development Activity16
Maintenance44
Community60
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
74/100Good
Architecture78
Code Quality72
Innovation75
Learning Curve70

html-to-image is a zero-dependency TypeScript library that captures a live DOM node and converts it into a PNG, JPEG, SVG, or raw canvas image directly in the browser, with no headless browser, screenshot API, or server round-trip involved. It works by cloning the target node, inlining its computed styles, embedding referenced web fonts and images as data URIs, and serializing the result into an SVG foreignObject that browsers can rasterize onto a canvas.

Originally forked from dom-to-image, it adds pixel-ratio control, cache-busting for cross-origin assets, pluggable node filtering, and a getFontEmbedCSS helper for reusing embedded font CSS across multiple captures. It ships as ESM, CommonJS, and a UMD bundle, and is framework-agnostic, usable from plain JavaScript, React, Vue, or any other DOM-based UI.

What You Get

  • Six top-level async functions - toPng, toJpeg, toSvg, toBlob, toCanvas, toPixelData - for exporting a DOM node in the format you need
  • Automatic embedding of external images, background images, and @font-face web fonts as inline data URIs so exports are self-contained
  • Pixel-ratio, canvas-size, and JPEG-quality controls for producing exports tuned to retina displays or fixed dimensions
  • A node filter callback for excluding elements (and their subtrees) from the captured output
  • getFontEmbedCSS for pre-computing font embed CSS once and reusing it across repeated captures
  • Zero runtime dependencies and dual ESM/CJS/UMD builds with bundled TypeScript types

Common Use Cases

  • Exporting a chart, dashboard widget, or report section as a downloadable PNG/JPEG
  • Generating shareable “share card” images from user-generated content, such as a completed quiz or profile card
  • Capturing an editable canvas or whiteboard as an image for saving or printing
  • Client-side screenshotting for bug reports or visual-regression snapshots without a headless browser
  • Producing preview thumbnails of live DOM content for social sharing or export

Under The Hood

Architecture The library exposes a single entrypoint (src/index.ts) with a small set of async functions - toSvg, toCanvas, toPixelData, toPng, toJpeg, toBlob, getFontEmbedCSS - that all stack on top of toSvg in a linear pipeline: clone the node, embed web fonts, embed images, apply style overrides, then serialize to an SVG data URI (optionally rasterized onto a canvas). clone-node.ts is the central abstraction: a recursive cloning routine that special-cases canvas, video, and iframe elements, walks shadow roots and slotted children, reattaches computed styles, recreates pseudo-elements (clone-pseudos.ts), and resurrects SVG <use> symbol definitions. embed-images.ts, embed-resources.ts, dataurl.ts, and embed-webfonts.ts each handle one async fetch-and-inline concern (image URLs, CSS background images, @font-face resources). There is no framework or DI container - it is a modular, single-purpose transform pipeline composed via async/await chains and Array.reduce for sequential async recursion over the DOM tree.

Tech Stack Written in TypeScript with zero runtime dependencies, built to dual ESM (build:esm) and CommonJS (build:cjs) outputs via tsc plus a UMD bundle via Rollup (@bubkoo/rollup-config). Linting runs through @bubkoo/eslint-config with lint-staged/husky pre-commit hooks, and releases are automated via semantic-release (@bubkoo/semantic-release-config). It targets the browser DOM/Canvas/SVG APIs directly and is framework-agnostic - the README shows plain JS, ES module, and React usage, but it has no dependency on any UI framework.

Code Quality Tests run under Karma with the Jasmine framework in a real Chrome instance (karma-chrome-launcher, karma-typescript) across roughly a dozen spec files (basic, canvas, embed, options, select, special, svg, video, webfont, image-error-handler), using pixelmatch for pixel-level image comparison and karma-coverage/Codecov for coverage reporting - a rigorous choice given that a DOM-rendering library can’t be meaningfully tested against a non-browser DOM shim. Code is consistently typed (a single Options interface in types.ts drives every function), uses camelCase naming and optional chaining throughout, and is enforced by ESLint/Prettier pre-commit hooks and a GitHub Actions CI workflow. Error handling is deliberately soft in places - cross-origin iframe cloning swallows errors silently and falls back to a shallow clone, and failed image loads are steered through an imagePlaceholder/onImageErrorHandler option rather than a thrown exception. Recent commit activity is low, though the repository is still occasionally maintained.

API Design The public API is deliberately minimal: a handful of top-level async functions that each take just a DOM node and an options object, with no class to instantiate and no provider/context to configure. Naming mirrors familiar browser Canvas API conventions (toDataURL-style methods), so the learning curve for a developer already comfortable with the DOM is close to zero - the README’s React example needs only a ref and one function call. Beyond matching its dom-to-image origins, it adds genuinely useful ergonomic options - pixelRatio, skipAutoScale, cacheBust, and a getFontEmbedCSS helper for caching font-embed work across repeated calls - without adding configuration overhead to the common case.

Used by 33 apps in this directory

TypeScript
99%
Other

Activepieces

Automation · AI Assistants

24,298

Open-source AI automation platform that converts 280+ workflow integrations into MCP servers for LLMs, with no-code builders and TypeScript extensibility.

View details
92
Repo Health
85
Technical
64
Dependency
Built with
TypeScript99%
Updated today
TypeScript
94%
MIT

Actual

Invoicing Finance

28,593

Local-first personal finance with envelope budgeting, end-to-end encryption, and multi-device sync — no subscription required.

View details
93
Repo Health
85
Technical
77
Dependency
Built with
TypeScript94%
Updated today
Python
90%
Apache 2.0

Apache Airflow

Data Engineering

46,755

Define, schedule, and monitor complex data workflows as Python code — with a powerful UI, 80+ provider integrations, and battle-tested scalability across thousands of production deployments.

View details
96
Repo Health
89
Technical
64
Dependency
Built with
Python90%
Updated yesterday
TypeScript
53%
MIT

Anarlog

Note Taking · AI Assistants · Productivity

9,252

Anarlog is an open-source, local-first AI meeting notetaker that records, transcribes, and summarizes meetings entirely on your device — no cloud lock-in, no mandatory account, and every note saved as a plain markdown file you own forever.

View details
86
Repo Health
77
Technical
68
Dependency
Built with
TypeScript53%
Rust35%
Updated today
Go
52%
MIT

Bytebase

Devops

14,467

An open-source database CI/CD and DevSecOps platform — schema migration review, GitOps-driven changes, data masking, and access control across MySQL, PostgreSQL, Oracle, Snowflake, MongoDB, and more.

View details
92
Repo Health
73
Technical
68
Dependency
Built with
Go52%
TypeScript39%
Updated yesterday
Ruby
49%
Other

Chatwoot

Customer Support

36,549

Open-source omnichannel customer support platform with AI-powered agents, live chat, and self-hosting — a full Intercom and Zendesk alternative.

View details
95
Repo Health
78
Technical
69
Dependency
Built with
Ruby49%
Vue26%
JavaScript22%
Updated yesterday
TypeScript
99%
AGPL 3.0

Cherry Studio

AI Assistants

51,521

All-in-one AI desktop client with 300+ assistants and multi-model support

View details
89
Repo Health
84
Technical
71
Dependency
Built with
TypeScript99%
Updated today
Java
78%
GPL 3.0

DataEase

Analytics · Data Engineering · AI Assistants

24,408

Open-source BI tool with drag-and-drop dashboards, 20+ data source connectors, and AI-powered natural language queries — a self-hosted alternative to Tableau.

View details
93
Repo Health
71
Technical
65
Dependency
Built with
Java78%
Vue22%
Updated 3 days ago
TypeScript
50%
Other

Dify

No Code Platforms · AI Development · Developer Tools

154,649

Visual LLM workflow platform with RAG pipelines, agent capabilities, and model management for building production AI applications.

View details
92
Repo Health
85
Technical
67
Dependency
Built with
TypeScript50%
Python46%
Updated yesterday

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search