Best HTML to Image APIs in 2026: Convert HTML to PNG, JPEG, WebP

Compare the top HTML-to-image APIs and libraries. Client-side, server-side, and cloud-based options for converting HTML to images.

Last updated: 2026-03-25

Try ScreenshotAPI free

5 free credits. No credit card required.

Start for free

Converting HTML to images is needed for social media cards, certificates, email previews, reports, and dynamic graphics. The challenge is that HTML rendering requires a browser engine for full fidelity. This guide compares every viable approach: client-side libraries, server-side tools, and cloud APIs.

Comparison Table

Tool/APITypeFull CSSJavaScriptFontsFormatsCost
ScreenshotAPICloud APIFullYesYesPNG, JPEG, WebP$20/500 credits
UrlboxCloud APIFullYesYesPNG, JPEG, WebP, PDF$19/month
ScreenshotOneCloud APIFullYesYesPNG, JPEG, WebP$17/month
html2canvasClient-side libPartialCurrent pagePartialPNG, JPEGFree
dom-to-imageClient-side libPartialCurrent pagePartialPNG, JPEG, SVGFree
SatoriServer-side libLimitedNoManualSVGFree
PuppeteerServer-side toolFullYesYesPNG, JPEG, WebPFree + infra
PlaywrightServer-side toolFullYesYesPNG, JPEGFree + infra

Cloud APIs (Best for Production)

ScreenshotAPI

ScreenshotAPI converts any URL to an image with full Chrome rendering. For HTML-to-image workflows, host your HTML template at a URL and capture it:

javascript
// Host your HTML template, then capture it const templateUrl = `https://yoursite.com/template?title=${encodeURIComponent('My Card')}`; const params = new URLSearchParams({ url: templateUrl, width: '1200', height: '630', type: 'png', waitUntil: 'networkidle' }); const response = await fetch( `https://screenshotapi.to/api/v1/screenshot?${params}`, { headers: { 'x-api-key': 'sk_live_your_api_key' } } ); const image = Buffer.from(await response.arrayBuffer());

Pros: Full CSS/JS rendering, web fonts, dark mode, all formats, no infrastructure. Cons: Requires hosting HTML at a URL, 2-5s response time.

Urlbox

Mature service with built-in HTML rendering endpoint. Supports passing HTML directly in the API request.

Pros: Direct HTML input (no hosting needed), retina rendering, S3 upload. Cons: No free tier, subscription pricing.

ScreenshotOne

Supports custom JavaScript and CSS injection, allowing you to modify the page before capture.

Pros: JS/CSS injection, interactive playground, proxy network. Cons: Monthly subscription, HTML must be at a URL.

Client-Side Libraries

html2canvas

The most popular client-side option. Reconstructs the visible DOM onto a canvas element.

javascript
import html2canvas from 'html2canvas'; const element = document.getElementById('card'); const canvas = await html2canvas(element, { scale: 2, // Retina quality useCORS: true, backgroundColor: null }); canvas.toBlob((blob) => { const url = URL.createObjectURL(blob); // Use the image }, 'image/png');

Pros: No server required, works in the browser, free. Cons: Cannot render external URLs, limited CSS Grid support, font rendering issues, no JS execution context.

dom-to-image

An alternative to html2canvas using SVG foreignObject:

javascript
import domtoimage from 'dom-to-image'; const node = document.getElementById('card'); const dataUrl = await domtoimage.toPng(node, { quality: 1.0 });

Pros: Better SVG support than html2canvas, lighter library. Cons: Same limitations as html2canvas, plus worse cross-browser support.

Server-Side Libraries

Satori (JSX to SVG)

Converts React/JSX components to SVG without a browser:

javascript
import satori from 'satori'; import { Resvg } from '@resvg/resvg-js'; const svg = await satori( <div style={{ display: 'flex', fontSize: 48, color: 'white', background: '#1a1a2e', width: '100%', height: '100%', alignItems: 'center', justifyContent: 'center' }}> Hello World </div>, { width: 1200, height: 630, fonts: [{ name: 'Inter', data: fontData }] } ); const resvg = new Resvg(svg); const png = resvg.render().asPng();

Pros: Extremely fast (<100ms), no browser needed, React component syntax. Cons: Very limited CSS (no Grid, limited Flexbox, no pseudo-elements, no animations), requires manual font loading.

Puppeteer / Playwright

Full browser rendering with page.setContent() for raw HTML:

javascript
import puppeteer from 'puppeteer'; const browser = await puppeteer.launch(); const page = await browser.newPage(); await page.setViewport({ width: 1200, height: 630 }); await page.setContent(htmlString, { waitUntil: 'networkidle0' }); await page.screenshot({ path: 'output.png' }); await browser.close();

Pros: Full CSS/JS rendering, free software, raw HTML input. Cons: Requires Chrome binary (~300 MB), memory-intensive, Docker complexity.

Decision Matrix

Use CaseBest ToolReason
Social media cardsScreenshotAPI or SatoriAPI for full fidelity, Satori for speed
Email previewsScreenshotAPIFull email CSS rendering
Client-side exporthtml2canvasOnly option without a server
Dynamic certificatesScreenshotAPIWeb fonts + complex layouts
OG images (Vercel)@vercel/ogFree, fast, integrated
OG images (general)ScreenshotAPIWorks on any platform
High-volume (10K+/day)Puppeteer + queueCost-effective at scale

CSS Feature Support

CSS Featurehtml2canvasSatoriPuppeteerScreenshotAPI
FlexboxPartialBasicFullFull
GridNoNoFullFull
Web FontsPartialManualFullFull
GradientsYesBasicFullFull
Box ShadowsYesNoFullFull
Pseudo-elementsNoNoFullFull
AnimationsNoNoYesYes
Media queriesNoNoYesYes

Verdict

For production HTML-to-image conversion with full rendering fidelity, ScreenshotAPI or Puppeteer are the best options. ScreenshotAPI removes infrastructure management. Puppeteer is free but requires server management.

For simple, template-based images without complex CSS, Satori is the fastest option.

For client-side only (no server), html2canvas is the only practical choice.

Next Steps

Frequently asked questions

What is the best way to convert HTML to an image?

For full rendering fidelity, use a headless browser (Puppeteer/Playwright) or a cloud API (ScreenshotAPI). For simple layouts without JavaScript, Satori converts JSX to SVG/PNG. Client-side libraries like html2canvas work for basic use cases.

Can html2canvas convert any HTML to an image?

No. html2canvas has significant limitations: it does not support CSS Grid fully, cannot render external iframes, has issues with web fonts, and only works on the current page's DOM (cannot load external URLs).

How do I convert an HTML email template to an image?

Host the HTML template at a URL (even a local server works), then use ScreenshotAPI to capture it at the desired dimensions. This gives you pixel-perfect rendering with full CSS and font support.

Is Satori the same as @vercel/og?

@vercel/og uses Satori under the hood. Satori converts React/JSX to SVG, and @vercel/og wraps it in an Edge Function that converts SVG to PNG. You can use Satori directly if you are not on Vercel.

Related resources

Start capturing screenshots today

Create a free account and get 5 credits to try the API. No credit card required. Pay only for what you use.