HTML to Image: Render HTML and CSS to PNG, JPEG or PDF avatar

HTML to Image: Render HTML and CSS to PNG, JPEG or PDF

Pricing

from $2.00 / 1,000 image rendereds

Go to Apify Store
HTML to Image: Render HTML and CSS to PNG, JPEG or PDF

HTML to Image: Render HTML and CSS to PNG, JPEG or PDF

Render your own HTML and CSS to PNG, JPEG, WebP or PDF with Chromium. Templates with {{variables}}, batches of up to 500 items, Google Fonts, retina scale, transparent background, crop to element. For OG images, certificates and invoices in Make, n8n, Zapier.

Pricing

from $2.00 / 1,000 image rendereds

Rating

0.0

(0)

Developer

Markus Heiß

Markus Heiß

Maintained by Community

Actor stats

0

Bookmarked

2

Total users

1

Monthly active users

2 days ago

Last modified

Features

Limited permissions

Share

Render HTML and CSS that you supply into PNG, JPEG, WebP or PDF files with a real Chromium browser. Put {{placeholders}} in your markup, pass variables, and get one file per render with a direct download link. Send a list of items to render hundreds of images from one template in a single run.

Built for automations: Open Graph and social images, certificates, invoices, receipts, charts, email banners, badges and thumbnails, generated from Make, n8n, Zapier, your backend or an AI agent. You send markup and data, you get back file URLs.

For screenshots of existing websites by URL, use our Website Screenshot Actor. This Actor is for HTML you write or generate yourself.

What it does

  • Renders your HTML as a fragment (<div>...</div>) or a full document, with optional extra CSS. Page margins are 0, so a 1200 x 630 element fills a 1200 x 630 image.
  • Fills templates: {{name}} inserts a value HTML-escaped, {{{name}}} inserts it raw (for markup or JSON arrays in scripts), {{user.name}} reads nested values. Unknown placeholders become empty and show up in missingVariables.
  • Batch mode: a list of items, each with its own variables and label, renders one file per item from the same template. Up to 500 items per run.
  • Built-in templates for people who only want to send data: an Open Graph card (1200 x 630) and a certificate (1600 x 1131).
  • Four formats: PNG (lossless, transparency), JPEG and WebP (small files, quality setting), PDF (selectable text, custom size or A3, A4, A5, Letter, Legal, portrait or landscape).
  • Sharp images: pixel density 1, 2 or 3 for retina output.
  • Crop to an element with a CSS selector, or capture the full content height.
  • Transparent background for PNG and WebP, for logos, badges and overlays.
  • Google Fonts by name, and it waits until web fonts have loaded. Images, fonts and scripts from public https and http URLs load normally, so Chart.js or other libraries from a CDN work.
  • Safe by design: the page cannot reach private or local network addresses, files on the server, or video and social platforms. See Limits.

Use cases

  • Open Graph and social images: one branded card per blog post, product or release, generated when the content is published.
  • Certificates: a personalized certificate per course participant as PNG or PDF.
  • Invoices and receipts: HTML invoice templates to A4 or Letter PDF from your order data.
  • Charts and reports: render a Chart.js or SVG chart to an image for an email or a Slack message.
  • Email banners and badges: personalized header images, status badges, score cards.
  • AI agents: let an agent write HTML and turn it into an image or PDF it can share.

Input

FieldDescriptionDefault
HTMLThe markup to render, with {{placeholders}}. Max 2 MB.
CSSExtra CSS for the head. Placeholders work here too.
Templatecustom (your HTML), og-card or certificatecustom
VariablesValues for the placeholders. Defaults for all items.
Items (batch)List of objects, one file each: {"label": "anna", "name": "Anna"} or {"label": "anna", "variables": {...}}
Output formatpng, jpeg, webp or pdfpng
Width, HeightViewport in CSS pixels, 16 to 40961200 x 630
Pixel density1, 2 or 31
QualityJPEG and WebP, 1 to 10090
Transparent backgroundPNG and WebP onlyoff
Crop to elementCSS selector like .card or #chart
Full pageCapture the full content height, up to 10,000 pxoff
Google FontsFamily names like Inter or Inter:wght@400;700
Wait for fontsWait until web fonts have loadedon
Extra wait (ms)For JavaScript charts or animations, 0 to 10,0000
PDF paper sizecustom (width x height), A4, A5, A3, Letter, Legalcustom
PDF landscapeFor the paper sizesoff
Escape variablesOff makes {{name}} insert raw HTMLon
File labelNames the file of a single render
Parallel renders1 to 52

Example, one Open Graph image from your own HTML:

{
"html": "<div class=\"card\"><h1>{{title}}</h1><p>{{subtitle}}</p></div>",
"css": ".card { width: 1200px; height: 630px; box-sizing: border-box; padding: 80px; background: #0f172a; color: #fff; font-family: Inter, sans-serif; } h1 { font-size: 76px; }",
"variables": { "title": "Version 2.0 is here", "subtitle": "Faster renders, new templates" },
"googleFonts": ["Inter:wght@400;700"],
"label": "og-release-2"
}

Example, three certificates as PDF from the built-in template:

{
"template": "certificate",
"format": "pdf",
"variables": { "date": "21 November 2026", "issuer": "Automation Academy" },
"items": [
{ "label": "cert-001", "name": "Example Company GmbH" },
{ "label": "cert-002", "name": "Sample Studio Ltd" },
{ "label": "cert-003", "name": "Demo Industries Inc" }
]
}

Output

One dataset row per file. The file itself is in the run's key-value store, and fileUrl links to it directly:

{
"index": 1,
"label": "og-release-2",
"format": "png",
"width": 1200,
"height": 630,
"pages": null,
"bytes": 338878,
"contentType": "image/png",
"key": "og-release-2.png",
"fileUrl": "https://api.apify.com/v2/key-value-stores/aBcD1234/records/og-release-2.png?signature=x1Y2z3",
"missingVariables": [],
"blockedRequests": [],
"renderMs": 1180,
"error": null
}
  • index is the position of the item in your list, starting at 1. A single render has index 1.
  • width and height are the real pixel size of the image, so pixel density 2 gives 2400 x 1260 for a 1200 x 630 viewport. For PDF they are the page size in CSS pixels (96 per inch), and pages is the page count.
  • key is the record name in the key-value store. It comes from the label, or image-001 without one. Duplicate labels get the index appended.
  • fileUrl is a signed link. It opens the file without an API token for as long as the run's storage is kept.
  • missingVariables lists placeholders that had no value. They were rendered as empty text.
  • blockedRequests lists up to 10 URLs the page tried to load that were refused (private addresses, video platforms, non-http schemes).
  • A failed item has error set and no file, for example No visible element matches the selector ".card".

Export the dataset as JSON, CSV or Excel, or read it through the Apify API. In Make, n8n or Zapier, run the Actor synchronously and read fileUrl from the dataset items.

Pricing

Pay per file: 0.002 USD per rendered file, so 2.00 USD per 1,000 images or PDFs. Invalid items, timeouts and other errors are free. Set the maximum charge in Apify to cap the cost of a run. The run stops cleanly when the limit is reached.

Each run also has a start fee of 0.00005 USD per GB of memory, which Apify shows as Actor Start, plus the platform usage of the run.

Limits

  • Max 500 items per run. Items beyond 500 are skipped and reported in one error row. Split larger lists into several runs.
  • Max 2 MB of HTML and CSS. Load large images from URLs instead of embedding them as base64.
  • Max 30 seconds per item, including loading fonts and images. A page that takes longer gets an error row and the run goes on.
  • Extra wait up to 10 seconds. Full page captures stop at 10,000 px height, or 16,384 device pixels at pixel density 2 and 3 (8,192 and 5,461 CSS pixels).
  • Large retina or full-page images need a lot of browser memory. The Actor then renders fewer items at the same time to fit into the run's memory. If the browser still runs out of memory, the item is retried once and then gets an error row. Give the run more memory for big batches at pixel density 3.
  • The page can load resources only from public http and https addresses. Requests to private and local networks (127.0.0.1, 10.x, 192.168.x, 169.254.x, localhost and the like), file:// URLs, WebSockets and WebRTC are blocked. Pages from YouTube, TikTok, Instagram, Vimeo, Facebook, X and similar platforms are not loaded.
  • Downloads and service workers are disabled. JavaScript runs, so charts and libraries work.
  • Relative URLs in your HTML have no base address. Use absolute URLs or add a <base href> tag.
  • Some image hosts refuse automated requests. Those images stay empty. Host important assets yourself or embed small ones as data URLs.
  • Crop to element and transparency are not used for PDF. For PDF, CSS @page rules win over the paper size setting, and print styles (@media print) apply.
  • Files stay in the run's key-value store for the data retention period of your Apify plan. Copy them elsewhere if you need them longer.
  • Data source: The HTML, CSS and variables you put into the input. The Actor renders them in a Chromium browser and loads only the external resources your HTML references, such as fonts and images from public URLs.
  • Your content: You are responsible for the markup, text, images, fonts and brands in your input and in the files it produces. Use only content you have the rights to, and respect the licenses of fonts and libraries you load.
  • Snapshot: Each file shows the page as it rendered at the time of the run. We do not guarantee that external resources load or look the same on every run.
  • For business use: This Actor is offered to businesses only, not to consumers.
  • Permitted use: Do not use it to create misleading documents, fake certificates or invoices presented as genuine, or content that infringes the rights of others.
  • Your responsibility: You choose the input and decide what happens with the results. If your input or the results contain personal data, you are the controller and need your own legal basis.
  • No circumvention: The Actor loads public resources as a normal browser. It does not bypass logins, paywalls, rate limits, blocks or access restrictions, and it blocks requests to private networks.
  • Request volume: Each render loads only the resources its HTML references, at most 5 renders at the same time. Do not use it to put load on third-party servers.
  • Provider: forgeloop, Markus Heiss, Austria. Imprint, Privacy Notice, Terms of Use.

Questions and issues

Open an issue on the Actor page.