# HTML to Image API

> HTML to Image is an HTML to image API that renders HTML code into a high-quality PNG image. Paid plans add custom dimensions and JPEG or WebP output.

**Endpoint:** `POST https://api.apiverve.com/v1/htmltoimage`  
**Category:** Data Conversion  
**Cost:** 20 credits per call  
**Canonical page:** https://apiverve.com/marketplace/htmltoimage

## Overview

Use it as an HTML to PNG API whenever you need to generate an image from HTML code: POST the markup and get back a download link. Perfect for generating social media previews, email images, report snapshots, and converting web content into shareable image formats.

## Authentication

Every call carries your key in an `x-api-key` header. The same key works across the whole
APIVerve catalog — there are no per-API subscriptions. Responses always use the same three
top-level keys: `status`, `error`, and `data`.

## Example request

```bash
curl -X POST "https://api.apiverve.com/v1/htmltoimage" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"html":"<html><head><style>body { font-family: Arial; padding: 20px; } h1 { color: #333; }</style></head><body><h1>Hello World</h1><p>This is a sample HTML document converted to an image.</p></body></html>","width":800,"height":600,"format":"png","fullPage":true}'
```

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `html` | string | Yes | HTML code to convert. length 0-500000 |
| `width` | integer | No | Image width in pixels. default 1280. range 100-3840. Premium field |
| `height` | integer | No | Image height in pixels. default 800. range 100-2160. Premium field |
| `format` | string | No | Output image format. default png. One of: png, jpeg, jpg, webp. Premium field |
| `fullPage` | boolean | No | Capture the whole page instead of cropping at the viewport height, so a long receipt, invoice or report comes back complete (default: false). default false |

## Response fields

- `width` — number · Generated image width in pixels
- `height` — number · Generated image height in pixels
- `format` — string · Output image format with file extension included
- `imageName` — string · Unique identifier for generated image file
- `expires` — number · Unix timestamp when download link expires
- `downloadURL` — string · Direct URL to download generated image file
- `htmlLength` — number · Character count of input HTML content

## Sample response

```json
{
  "status": "ok",
  "error": null,
  "data": {
    "width": 800,
    "height": 600,
    "format": "png",
    "imageName": "bf3d3d67-bc6e-477b-a916-560b895f8091.png",
    "expires": 1789676439207,
    "downloadURL": "https://storage.googleapis.com/apiverve/APIData/htmltoimage/bf3d3d67-bc6e-477b-a916-560b895f8091.png?GoogleAccessId=635500398038-compute%40developer.gserviceaccount.com&Expires=1789676439&Signature=Uw7imp8TVuygEgWhdLAmK8%2Byk0NoZmtdLEX9MrDHjlWDYyB28y7zbCxVuD%2BF%2F6Iij5zi%2FhvDoJnuhNT6a2Yl85gw5nWGt750Ai4gup46dQQt0vrsUpD99IPTfTh21DWd4WqE7VCWlIlou7WwNUn620WgWM3ScGi13dCB81Qyb4WuxrdcNal8WrUYX9nZ12h%2B7BZs65Tyw0V4StbvsYxXKqySkF4aQ8J1QbdhUny9WyptE3qNT%2FyM4m2%2F%2FJAOq32bQsSWj8%2BycWEhtifIgpJe4LTBBeqtHBePrIQSrYNRdOwhjaTzj%2BShSeox5wPztiaoRyi1DGIx4FIIstS2dAdQ6Q%3D%3D",
    "htmlLength": 197
  }
}
```

## Use cases

- **Social Media** — Generate Open Graph images and social media previews from HTML templates
- **Email Marketing** — Convert HTML content to images for email compatibility across clients
- **Report Generation** — Create visual snapshots of HTML reports and dashboards
- **Documentation** — Generate images from HTML documentation for offline use

## SDKs

- **npm** — `npm install @apiverve/htmltoimage` (https://www.npmjs.com/package/@apiverve/htmltoimage)
- **PyPI** — `pip install apiverve-htmltoimage` (https://pypi.org/project/apiverve-htmltoimage/)
- **NuGet** — `dotnet add package APIVerve.API.HTMLtoImage` (https://www.nuget.org/packages/APIVerve.API.HTMLtoImage)
- **Source** — https://github.com/apiverve/htmltoimage-api

## More

- Full reference: https://docs.apiverve.com/ref/htmltoimage
- Get an API key: https://dashboard.apiverve.com
- Full catalog: https://apiverve.com/marketplace
