Quick Start

Render your first image in five minutes. One Node.js example, end to end.

1. Get your API key

Sign up at app.html2img.com. Copy your key from the dashboard. The free tier covers 25 renders a month.

Keep your API key out of client-side code. Store it in an environment variable on your server.

2. Send your first request

const response = await fetch('https://app.html2img.com/api/html', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': process.env.HTML2IMG_API_KEY
  },
  body: JSON.stringify({
    html: '<div style="padding: 40px; font-family: Inter, sans-serif; font-size: 48px;">Hello from html2img</div>',
    width: 1200,
    height: 630
  })
});

const { url } = await response.json();
console.log('PNG ready at', url);

The response includes a CDN URL on i.html2img.com. The image stays available for the lifetime of the account.

3. Inspect the response

{
  "success": true,
  "credits_remaining": 24,
  "id": "abc123",
  "url": "https://i.html2img.com/abc123.png"
}

A 422 means a validation error. A 504 means the render exceeded the 30 second sync budget; switch to webhook_url. See the getting started guide for the full error reference.

What next

Need a different language? See the language guides.

Need to tweak the render? See the parameters reference.

Looking for a pre-built design instead of writing HTML? Browse the templates gallery and POST a JSON payload to a named endpoint.