# HTML to image API: fields, sample output and cost per 1,000 rows

Render an HTML snippet to a PNG, JPEG or WEBP image at any width, with retina scaling and transparent background.

This is the reference for the Actor `v0iddo/html-to-image`: what is in every output row, what the input takes, and what a run costs. Values below come from a real run of the Actor.

## At a glance

| | |
| --- | --- |
| Actor | `v0iddo/html-to-image` |
| Store page | [HTML to image API](https://apify.com/v0iddo/html-to-image) |
| Output | one row per result, as JSON, CSV, Excel or HTML |
| Fields per row | 13 (7 number, 4 text, 1 URL, 1 true/false) |
| Cap on results | the run options on Apify |
| Price | $3.40 per 1,000 results |

## Output fields

Each result is one row with these fields (fields that name people are left out):

| Field | Type | Meaning | Sample value |
| --- | --- | --- | --- |
| `index` | number | # | 0 |
| `file_url` | URL | File | https://api.apify.com/v2/key-value-stores/LCqVWrkEdfnbldvyA/records... |
| `filename` | text | File name | image.png |
| `mime` | text | Type | image/png |
| `bytes` | number | Bytes | 5844 |
| `credits` | number | Credits | 3 |
| `ms` | number | Time (ms) | 2912 |
| `file_key` | text |  | result-001-image.png |
| `width` | number |  | 600 |
| `height` | number |  | 200 |
| `format` | text |  | png |
| `blocked_requests` | number |  | 0 |
| `truncated` | true/false |  | false |

## One record

```json
{
  "index": 0,
  "file_url": "https://api.apify.com/v2/key-value-stores/LCqVWrkEdfnbldvyA/records/result-001-image.png?signature=1oigqCJ4fTNqCDYZNG0WA",
  "file_key": "result-001-image.png",
  "filename": "image.png",
  "mime": "image/png",
  "bytes": 5844,
  "width": 600,
  "height": 200,
  "format": "png",
  "blocked_requests": 0,
  "truncated": false,
  "credits": 3,
  "ms": 2912
}
```

## Input parameters

| Parameter | Type | Required | Default | What it does |
| --- | --- | --- | --- | --- |
| `html` | string | yes | <div style='font:700 48px sans-serif;padding:40px;background:#1fa37... | The HTML document or fragment (UTF-8, up to 2 MB). |
| `width` | integer | no | 1200 | Viewport width in CSS px |
| `height` | integer | no | 200 | Viewport height in CSS px; omit for a full-page image that fits the content |
| `format` | string | no | png | File format of the result. |
| `quality` | integer | no | 90 | jpeg / webp quality |
| `devicescalefactor` | string | no |  | Pixel density (2 = retina) (a number) |
| `transparent` | boolean | no | false | Transparent page background (png / webp only) |
| `items` | array | no |  | Optional. A list of input objects with the same fields as above; every object is processed in its own right and the top-level fields act as shared defaults. |

## Ready-made examples

Saved inputs on Apify: run one as it is, or copy it and change the values.

- [Turn HTML into a 1200 x 630 social card PNG](https://apify.com/v0iddo/html-to-image/examples/html-to-png-social-card)

## Cost per 1,000 rows

$3.40 per 1,000 results. You pay per result row. There is no separate charge per run. Higher Apify plans pay less per result, down to $2.38 per 1,000.

| Results | Cost at the listed price | Cost at the lowest plan price |
| --- | --- | --- |
| 100 | $0.34 | $0.24 |
| 1,000 | $3.40 | $2.38 |
| 10,000 | $34.00 | $23.80 |
| 100,000 | $340.00 | $238.00 |

The figures are the listed price times the number of results. The `maximum results` limit and the maximum cost setting in the run options both stop a run before it spends more than you planned.

## Get the rows as CSV over HTTP

One request starts a run, waits for it and returns the dataset. The `format` parameter picks the file type and `fields` picks the columns. Replace the token with the one from Apify Console, Settings, Integrations.

```bash
curl -X POST "https://api.apify.com/v2/acts/v0iddo~html-to-image/run-sync-get-dataset-items?format=csv&fields=index,file_url,filename" \
  -H "Authorization: Bearer YOUR_APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"html": "<div style='\''font:700 48px sans-serif;padding:40px;background:#1fa37a;color:#fff'\''>Hello, v&oslash;iddo</div>", "width": 600, "height": 200}'
```

## Links

- Actor on the Apify Store: [HTML to image API](https://apify.com/v0iddo/html-to-image)
- Guide with the Python and JavaScript code: [https://voidd0.github.io/html-to-image/](https://voidd0.github.io/html-to-image/)
- Step by step: [https://voiddo.com/export/html-to-image/](https://voiddo.com/export/html-to-image/)

