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,242 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
54 /100 Fair
Development Activity 12
Maintenance 44
Community 60
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
74 /100 Good
Architecture 78
Code Quality 72
Innovation 75
Learning Curve 70

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 34 apps in this directory

TypeScript
100%
Other

Activepieces

AI Assistants · Automation · Mcp

24,756

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
TypeScript 100%
Updated 4 days ago
TypeScript
95%
MIT

Actual

Invoicing Finance

29,186

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
73
Dependency
Built with
TypeScript 95%
Updated 4 days ago
Python
89%
Apache 2.0

Apache Airflow

Data Engineering

46,995

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
Python 89%
Updated 4 days ago
TypeScript
54%
MIT

Anarlog

AI Assistants · Note Taking · Productivity

9,404

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
TypeScript 54%
Rust 34%
Updated 4 days ago
Go
49%
MIT

Bytebase

Devops

14,512

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
Go 49%
TypeScript 42%
Updated 4 days ago
Ruby
50%
Other

Chatwoot

Customer Support

37,254

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
Ruby 50%
Vue 25%
JavaScript 22%
Updated 5 days ago
TypeScript
99%
AGPL 3.0

Cherry Studio

AI Assistants

52,202

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

View details
89
Repo Health
84
Technical
70
Dependency
Built with
TypeScript 99%
Updated 4 days ago
Java
70%
GPL 3.0

DataEase

AI Assistants · Analytics · Data Engineering

24,558

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
94
Repo Health
71
Technical
65
Dependency
Built with
Java 70%
Vue 29%
Updated 4 days ago
TypeScript
50%
Other

Dify

AI Development · Design Tools · Developer Tools

157,364

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

View details
92
Repo Health
85
Technical
66
Dependency
Built with
TypeScript 50%
Python 47%
Updated 4 days ago

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