← All libraries

html2canvas

JavaScript
↗ Official site

Images & file upload

Take screenshots of any part of your webpage.

What it does

html2canvas captures any DOM element and converts it to an image. Useful for 'download as image' features, social sharing cards, or report generation.

When to use it

Use this when you need users to export or download a section of your webpage as an image.

Real example

You're building a 'Share your result' feature that lets users download their quiz results as a card. Prompt: 'Use html2canvas to capture the #result-card div. In the download button's click handler, call html2canvas(document.getElementById("result-card")) then create a link element with the canvas.toDataURL() as href and trigger a click to download.'

Good to know

Not perfect — some CSS properties don't render correctly. For complex layouts, a server-side screenshot (Playwright) is more reliable.

Alternatives

Playwright (server-side)

Install

$ npm install html2canvas

Use cases

screenshotimage exportshare cardPDF export

Language

JavaScript

Category

Images & file upload

More in Images & file upload

Other tools in the same category