BASE

html-to-image

html-to-image

Web framework / library · Free

A library for converting DOM into PNG, JPEG, or SVG: it helps export user-created cards and application visual previews.

Also known as: bubkoo/html-to-image; html2image; dom-to-image

Resource illustration: html-to-image

Open resource ↗

What you can use for free

Code and local use under MIT.

Paid features and costs

Computing resources, self-hosting, and external services are paid for separately if used.

Access and limitations

Code and local use under MIT. Computing resources, self-hosting, and external services are paid for separately if used.

Use cases

  • Export a user-created card as an image
  • Run conversion and check fonts, dimensions, and generated image content

Example workflow

A possible workflow; this is not a report of hands-on testing.

Export a user-created card as an image.

Before you start

  • Web application source code and the intended workflow.
  • The project's framework and runtime version.

Steps

  1. Select the DOM element to convert into PNG, JPEG, or SVG.
  2. Run conversion and check fonts, dimensions, and generated image content.
  3. Add real data and error handling; check the production build.

Check your result

  • The workflow works after a page refresh and with invalid data.
  • The bundle, server rendering, and supported browsers suit the project.

Choosing html-to-image

Export a user-created card as an image

Choose this when

  • Export a user-created card as an image
  • Run conversion and check fonts, dimensions, and generated image content

Requirements

  • The browser must support Promise and SVG foreignObject; the API takes a DOM node and returns a Promise.

Things to consider

  • Costs and limits of free use: Computing resources, self-hosting, and external services are paid for separately if used.
  • Terms of use: MIT for the code; dependencies have separate licenses.
  • A tainted canvas may prevent rendering; huge DOM content encounters the dataURI limit. Internet Explorer is unsupported.

Frequently asked questions

What can you use for free in html-to-image?

Code and local use under MIT.

What additional costs might arise with html-to-image?

Computing resources, self-hosting, and external services are paid for separately if used.

What terms of use matter for html-to-image?

MIT for the code; dependencies have separate licenses.

How do you get started with html-to-image?

Select the DOM element to convert into PNG, JPEG, or SVG. Run conversion and check fonts, dimensions, and generated image content. Add real data and error handling; check the production build.

Why does DOM export sometimes produce blank areas or an error?

The library clones DOM/styles, loads and embeds fonts/images into an SVG foreignObject, then renders to canvas if needed. Failed image loading without imagePlaceholder leaves a blank area. fontEmbedCSS reuses prepared fonts; filter excludes subtrees but is not called for the root node.

License

MIT for the code; dependencies have separate licenses.

MIT — permissive license

You can use, modify, distribute, and sell the code, including in a closed-source commercial product. When sharing copies or substantial portions of the code, retain the license text and copyright notice. You do not need to open-source your entire project; the author provides no warranties.

License terms

Technologies and topics

  • html-to-image
  • web
  • Development

Sources

Other resources