Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The html-to-image npm package turns a live browser DOM node into an image or rendered object. Install it with npm i html-to-image, pass an element such as a div to toPng, and use the returned data URL where your application needs it. It is a browser-side DOM capture library—not a tool that accepts an arbitrary website URL or renders HTML in a Node.js server by itself.

What html-to-image does—and what it does not do

html-to-image on npm captures a DOM node available in a browser. It reconstructs the selected element, including styles and supported assets, then renders it using SVG and canvas. Its documented output methods provide PNG, JPEG, SVG, Blob, Canvas, or pixel data.

This input model matters: the package expects a node such as an element obtained from the page, not a URL such as https://example.com. If your code runs on a server and starts with HTML rather than an existing browser DOM, you need a browser-rendering approach instead. For example, node-html-to-image describes a Node.js workflow that uses Puppeteer in headless mode. These tools address different environments; the available documentation does not establish a universal performance winner.

Install the package

From your project directory, install the package with npm:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
ClearClick AV to HDMI Converter 3.0 (Third Generation) - 1080P RCA or S-Video to HDMI Upscaler - with Remote Control for Image Adjustment - VHS, VCR, Camcorder, DVD, TV, Gaming Systems, PAL, NTSC
  • AV To HDMI Converter 3.0 - Convert & Upscale RCA / S-Video / Analog Video Input to HDMI (TV or Monitor) at 1080P or 720P - Plug and Play Adapter with No Computer or Drivers Required
  • Upscaler Compatible with VCR, VHS, Camcorders, Hi8, Gaming Systems, Set-Top Boxes, DVD Players, & More. RCA/AV/Composite and S-Video Input. HDMI Output. Works with PAL and NTSC. (Important Note: Does NOT Downscale HDMI to RCA/AV/S-Video)
  • NEW! Remote Control Included - Fine Tune Your Video's Image Quality By Adjusting Brightness, Contrast, Saturation, Hue, Resolution (1080P or 720P), Aspect Ratio (Preserve Original 4:3 Look with Black Bars or Stretch To 16:9 HD Widescreen To Fill Your TV Screen)
  • NEW! S-Video Input - Allows S-Video Input From Camcorder, VCR, DVD Player, & More - Providing The Highest Possible Video Quality From These Sources (S-Video Cable Not Included - RCA/AV Cable Required For Audio Signal)
  • Includes 2-Year Warranty & Tech Support from ClearClick, a USA-Based Small Business (Extendable to 3 Years for Free - See User's Manual)
npm i html-to-image

The project README also documents npm install --save html-to-image. Import the functions you need in an ES module, or use the documented CommonJS style:

import { toPng } from 'html-to-image';

// CommonJS alternative:
// const htmlToImage = require('html-to-image');

Use the package in browser code where the target node exists. In a React component, the documented pattern is to attach a ref to the element and pass ref.current to a capture function after the node has rendered.

Capture a DOM element as PNG

This minimal browser example captures an element with the ID card, then displays the resulting PNG data URL in a new image element:

import { toPng } from 'html-to-image';

async function captureCard() {
  const node = document.getElementById('card');
  if (!node) throw new Error('Could not find #card');

  const dataUrl = await toPng(node);
  const preview = new Image();
  preview.src = dataUrl;
  document.body.appendChild(preview);
}

captureCard().catch((error) => {
  console.error('Image capture failed:', error);
});

The functions return promises, so await the result or handle rejection. The element must exist in the browser DOM when you call the function. A screenshot is a rendered image of that node, not a live link to the original element.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

React ref example

In React, call the capture function from an event handler once the component has mounted and its ref points to the intended element:

Rank #2
GINGIN AV to HDMI Converter, AV to HDMI Adapter Support 720p/1080p for PS1/PS2/PS3/Xbox 360/WII/N64/SNES/STB/VHS/VCR/Blue-Ray DVD Players
  • Composite to HDMI Converter: Converts analog AV composite (Yellow, White, Red) input to HDMI 720P/1080P (60HZ) output, displayed on smart TV, Projector or HD Display, which bring back your old and cherish memories.
  • Plug to Play: This HDMI Converter no extra drivers need, just plug and play,easy to use. Please hook up the USB Power Cable (included) to 5V power source during use. Note: The Video Converters only support converts AV to HDMI, can't converts HDMI to AV.
  • Widely Used: This composite to hdmi adapter is widely applied to PS1, PS2, PS3, Xbox, N64, Wii, STB, VHS, VCR, DVD Players and other devices with standard composite AV input. Note: It can only be used when PS2 is set to RGB output.
  • Wide Compatibility: This Video Audio Converter Adapter supports source formats of PAL, NTSC3.58, NTSC4.43, SECAM, PAL/M, PAL/N standard TV. Provide advanced signal processing with great precision, colors, resolutions, and details. Important Note: This converter can't improve video quality!
  • Attention & Package: Please ensure to connect this av hdmi converter to power source to make it work. Package include: 1*AV to HDMI Adaptor, 1*USB Power Cable(adapter not included), 1*User Manual.
import { useRef } from 'react';
import { toPng } from 'html-to-image';

export function ExportCard() {
  const cardRef = useRef(null);

  async function downloadCard() {
    if (!cardRef.current) return;
    const dataUrl = await toPng(cardRef.current);
    const link = document.createElement('a');
    link.download = 'card.png';
    link.href = dataUrl;
    link.click();
  }

  return (
    <>
      <div ref={cardRef}>Content to export</div>
      <button onClick={downloadCard}>Download PNG</button>
    </>
  );
}

For production code, handle a rejected promise and provide a visible error state. If the ref is still null, the target has not mounted or the capture ran before the element was available.

Choose the output method

Method Result Useful when
toPng(node) PNG data URL You need a lossless raster image or a directly usable img source.
toJpeg(node, options) JPEG data URL You need JPEG output and want to set compression quality.
toSvg(node) SVG data URL You want the serialized SVG representation rather than a raster output.
toBlob(node) Image Blob Your downstream code expects a binary object, for example for a file operation or object URL.
toCanvas(node) HTMLCanvasElement You need to continue working with the rendered canvas in browser code.
toPixelData(node) Uint8Array containing RGBA pixel data You need pixel values for image processing or analysis.

JPEG quality is configurable from 0 to 1; the README documents a default of 1.0. For example:

import { toJpeg } from 'html-to-image';

const node = document.getElementById('card');
if (!node) throw new Error('Could not find #card');
const jpegDataUrl = await toJpeg(node, { quality: 0.85 });

Prefer the result type your next step actually consumes. A data URL is convenient for assigning to an image source, while a Blob is a binary object and a Canvas is useful when additional browser-side drawing is required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Options for controlling the capture

The README documents options that affect filtering, appearance, sizing, and resource handling. Pass them as an options object to the selected conversion function.

Option Purpose and important behavior
filter Exclude nodes from the capture. Excluding a node also excludes its children. The filter is not called on the root node itself.
backgroundColor Set the rendered background color.
width, height Set dimensions used for the rendered node.
canvasWidth, canvasHeight Set the canvas dimensions separately from the node dimensions.
style Apply style overrides to the cloned node for rendering.
quality Set JPEG quality on the documented 0-to-1 scale.
cacheBust Control cache-busting behavior for resources.
includeQueryParams Control how query parameters are included when handling resource URLs.
imagePlaceholder Provide a placeholder for images that cannot be loaded.
pixelRatio Control the pixel ratio used for rendering.
Preferred font format Choose a preferred font format when embedding fonts.

For example, filter out a known child element and set a background for a PNG export:

Rank #3
RuiPuo RCA to HDMI Converter, AV to HDMI Adapter Support 1080P, PAL/NTSC Compatible with WII/WII U/PS one/PS2/PS3/STB/Xbox/VHS/VCR/Blue-Ray DVD ect.
  • Input: RCA, Output: HDMI; Converts Analog Composite Input to HDMI 1080p or 720p Output.
  • RCA to HDMI Converter - Plug and Play, Easy to Install and Operate, Powered by External USB Cable.
  • RCA to HDMI Converter supports connecting HDMI capture card (note that we do not include HDMI capture card).
  • Composite to HDMI Converter Widely Applied to PS One, PS2, PS3, N64, WII, WII U, STB, VHS, VCR, Blue-Ray DVD Players Projector (Note: It can only be used when PS2 is set to RGB output).
  • AV to HDMI Converter Support PAL, NTSC3.58, NTSC4.43, SECAM, PAL/M, PAL/N tv format.
import { toPng } from 'html-to-image';

const node = document.getElementById('card');
if (!node) throw new Error('Could not find #card');

const dataUrl = await toPng(node, {
  backgroundColor: '#ffffff',
  filter: (child) => !child.classList?.contains('no-export'),
  pixelRatio: 2
});

Because the filter does not run on the root node, put an exclusion target inside the captured element if you intend to remove it with this callback. Validate dimensions and pixel ratio with the actual content: increasing rendered dimensions can increase memory use, and the documentation provides no universal maximum capture size.

How rendering works and why captures can differ

The library does not simply take a native screenshot of the browser viewport. Its documented process clones the selected element tree, copies computed styles, recreates pseudo-elements, embeds fonts and images, serializes the clone, and wraps it in SVG <foreignObject>. Raster output and pixel data use an off-screen canvas.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

This reconstruction explains why a capture can differ from what you see on screen. If a visual detail is missing, inspect whether it comes from computed styles, a pseudo-element, a font or image that can be embedded, or a canvas whose contents are restricted by browser security. The cloned render can only include what the process can reproduce and access.

Fonts, images, and cross-origin canvas issues

The README describes embedding fonts and images as part of rendering, but that does not remove browser security restrictions. In particular, the project warns that a canvas inside the captured node may prevent successful rendering if it is tainted by cross-origin content.

  • Missing image: confirm the image has loaded and that its resource can be fetched and embedded in the capture. The imagePlaceholder option can supply fallback content for images that cannot be loaded.
  • Missing font or changed text wrapping: check that the intended font has loaded before capture and is available to the browser’s rendering process. The package documents font embedding and a preferred font format option.
  • Canvas-related failure: investigate whether a canvas inside the target contains cross-origin content that taints it. The README says this can prevent successful rendering; it does not imply every canvas capture will fail.
  • Stale resource result: review the documented cacheBust and includeQueryParams options for the resource URLs involved.

Do not assume that a successful DOM lookup guarantees all external assets are capture-ready. Wait for application data and required assets before invoking the conversion, and handle failures rather than silently exporting an incomplete image.

Rank #4
ABLEWE RCA to HDMI,AV to HDMI Converter, 1080P Mini RCA Composite CVBS Video Audio Converter Adapter Supporting PAL/NTSC for TV/PC/ PS3/ STB/Xbox VHS/VCR/Blue-Ray DVD Players
  • RCA to HDMI Converter: Converts analog RCA composite (Yellow, White, Red) input to HDMI 720P/1080P (60HZ) output,displayed on HDTV/Monitor,which can bring back your childhood memories.
  • Plug to Play: ABLEWE Mini RCA to HDMI converter no extra drivers need, just plug and play,easy to use.Please hook up the USB power cable (included) to 5V power source during use.
  • Wide Compatibility: Support source formats of PAL, NTSC3.58, NTSC4.43, SECAM, PAL/M, PAL/N standard TV. Provide advanced signal processing with great precision, colors, resolutions, and details.
  • Widely Used:Widely applied to PS2,PS3,Xbox,N64, WII, STB, VHS, VCR, DVD Players and other devices with standard composite AV input.
  • Attention & Package:Please ensure to connect this rca to hdmi converter to power source to make it work.Package include:1*RCA to HDMI Converter,1*usb power cable(adapter not included),1*User Manual.

Browser support and size limits

The README requires Promise and SVG <foreignObject> support. It explicitly says Internet Explorer is unsupported because it does not support SVG <foreignObject>. The README’s browser-testing note lists Chrome 49, Firefox 45, and Safari 16 “at the time of writing”; that is historical documentation, not a current browser-support guarantee.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The project also warns that very large DOM trees can exceed varying data URI limits. It does not publish one universal size threshold. If a large capture fails, reduce the captured content or its rendered dimensions and test in the browser environment you actually support; do not rely on a size cutoff inferred from another browser.

Does html-to-image work in Node.js?

The documented API takes a DOM node and relies on browser capabilities, including SVG <foreignObject>. A plain Node.js process has no page DOM to pass to toPng. If the input is a live element in a browser application, html-to-image fits that workflow. If you need to start from HTML in a Node.js service, a tool such as node-html-to-image describes a Puppeteer-based headless-browser workflow. Choose based on where the HTML exists and whether deploying a headless browser is appropriate; the cited project descriptions do not provide a comparable benchmark.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If you need an image of a website by URL rather than a DOM node already in your application, ScreenshotNeo is a website screenshot API and MCP server. One GET request returns PNG, JPEG, WebP, or PDF output. For the same API call in the supported client examples, see the ScreenshotNeo documentation.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo removes cookie/consent banners, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, with response headers indicating the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The Free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 screenshots.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Sign up for ScreenshotNeo’s free plan to try 1,000 screenshots a month with no card.

Best Value
BD&M RCA to HDMI Converter, AV to HDMI Adapter Supports PAL/NTSC for PS2, PS3, Xbox, VHS, VCR, DVD Players
  • Convert RCA to HDMI Instantly – BD&M RCA to HDMI Converter easily converts analog RCA/composite AV signals to HDMI output, allowing you to connect older devices to modern HDTVs, monitors, and projectors with clear video and audio quality.
  • Wide Device Compatibility – Supports VHS players, VCRs, DVD players, camcorders, retro gaming consoles, and more including PS1, PS2, PS3, Xbox, N64, Wii, and older AV devices with standard RCA output.
  • 1080P HDMI Output – Advanced signal processing delivers stable and sharp video output with support for 720P/1080P HDMI resolution, improving compatibility with modern TVs and displays.
  • Plug & Play Setup – No drivers or software required. Simply connect the RCA cables, HDMI cable, and included USB power cable for quick and easy installation in minutes.
  • Compact & Reliable Design – Lightweight mini converter design makes it perfect for home entertainment setups, retro gaming, travel, or converting old media collections while maintaining stable performance.

Troubleshooting common failures

Symptom Likely cause What to do
The call fails before producing output The node is missing, not mounted yet, or the promise rejected during rendering. Check the selector or ref, call after the element exists, and catch the promise rejection so the actual error is visible.
Images are missing A resource may not have loaded or may not be embeddable. Wait for the resource, inspect access and loading in the browser, and consider imagePlaceholder for unavailable images.
Text uses a fallback font or wraps differently The intended font may not be loaded or embedded when capture begins. Wait until fonts are ready in the application, then capture; review the preferred font format option.
Capture fails when the element includes a canvas The canvas may be tainted by cross-origin content. Check the canvas security state and the origin of its content; the README identifies tainting as a possible failure condition.
Output is blank or incomplete for a very large node A large DOM tree may run into browser-specific data URI limits or resource constraints. Capture a smaller region or reduce output dimensions, then test in the target browser. No universal limit is documented.
A browser behaves differently from expected Required Promise or SVG <foreignObject> support may be absent, or the browser version may differ from the README’s historical testing note. Use a browser that supports the required features and validate the exact browser versions in your support matrix. Internet Explorer is documented as unsupported.

Performance, reliability, and cost considerations

Rendering entails cloning and serializing the node, embedding assets, and drawing through SVG and canvas. Large trees and high output dimensions therefore deserve practical testing in the browsers and devices your application targets. The documentation warns about data URI limits for large captures but gives no fixed threshold or performance benchmark.

For reliability, capture only after the UI and required assets are ready, choose a smaller target when a full section is unnecessary, and handle rejected promises. For output pipelines, pick a return type that avoids unnecessary conversions—for example, use a Blob when the next step consumes binary data rather than converting formats repeatedly.

The npm documentation establishes no paid service requirement for using the library; it is installed as an npm package. Operational costs depend on your application and hosting choices, particularly if you choose a separate headless-browser service for server-side rendering. No pricing comparison or benchmark between the libraries is established by their cited documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently asked questions

Can html-to-image capture a whole web page?

Its documented functions accept a DOM node. You can pass a page-level node if that is the content you want to render, but it is not a URL-based website screenshot endpoint.

Can I get raw pixel values instead of a file?

Yes. The documented toPixelData(node) method returns a Uint8Array containing RGBA pixel data.

Does it support Internet Explorer?

No. The README says Internet Explorer is unsupported because it lacks SVG <foreignObject> support.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.