HTML and CSS to images in n8n, in one workflow.

A ready-made workflow template that renders any HTML and CSS to PNG, JPEG or WebP with codetoimage. Start it by hand or from a webhook, get the image back as a file or as a hosted link, and get readable errors instead of failed executions.

The n8n workflow: manual trigger and webhook feed one HTTP Request to codetoimage, then split into image file, hosted link or error response

What you get

Two ways in

Click Test workflow and edit the sample fields, or POST JSON to the built-in webhook from any app. Swap the manual trigger for RSS, Airtable or Google Sheets to automate it.

Two ways out

The image as a binary file, ready for Slack, Gmail, Google Drive, S3 or Telegram nodes. Or a temporary hosted URL you can paste into a sheet, a CMS or an og:image tag.

Readable errors

A wrong key, an empty credit pool or invalid input comes back as { error, message } on its own branch, not as a red execution you have to open.

Install in 2 minutes

  1. Get a free API key (50 renders a month, no watermark).
  2. Download the workflow JSON below and import it in n8n: Workflows → Import from file.
  3. Open the Render with Code to Image node and create a Header Auth credential: name x-api-key, value = your key.
  4. Paste your HTML and CSS into Sample input and click Test workflow. The sample card renders as a 1200 × 630 PNG.
Download workflow JSON
In reviewSubmitted to the n8n template library. Until it is listed, import the JSON.

Call it from a webhook

Activate the workflow, then send the same fields as JSON. With output: "file" the response is the image; with output: "url" it is JSON with url and expires_at.

curl -X POST https://YOUR-N8N/webhook/codetoimage \
  -H 'content-type: application/json' \
  -d '{"html":"<h1>Hi</h1>","css":"h1{color:red}","width":800,"height":400,"format":"png","output":"file"}' \
  --output image.png

Fields

FieldRequiredDefaultNotes
htmlyes–Any HTML. Inline <style> and Google Fonts work.
cssnoemptyExtra stylesheet, applied on top of the HTML.
width, heightno1200 × 6301 to 4096 px.
formatnopngpng, jpeg or webp.
outputnofilefile = binary image, url = temporary hosted link.

Any other render API option (quality, transparent, backgroundColor, saved templates with variables) can be added to the JSON body of the HTTP Request node.

FAQ

Do I need a community node to use codetoimage in n8n?

No. The template uses only built-in nodes (Webhook, Edit Fields, HTTP Request, If, Respond to Webhook), so it works on n8n Cloud and on self-hosted instances without installing anything. Your API key lives in a standard Header Auth credential.

How do I generate Open Graph images or social cards for new content?

Replace the manual trigger with the trigger you already use (RSS, Airtable, Google Sheets, Notion, a CMS webhook), map the title and other fields into the html field, keep the rest of the workflow as is. The image comes back as a binary file you can upload anywhere, or as a hosted URL you can write back into your CMS.

What does a render cost from n8n?

The same as from the REST API, CLI or MCP server: one render is one credit. The free tier gives you 50 renders a month with no watermark; paid plans start at $9 a month for 1,000 renders, and prepaid packs start at $5.

Render your first image from n8n

Free tier: 50 renders/month, no watermark, no credit card.