Render an HTML snippet to a PNG, JPEG or WEBP image at any width, with retina scaling and transparent background.
This tutorial shows what the Actor v0iddo/html-to-image returns, how to run it on the Apify Store without code, and how to call it from Python and cURL.
What data you get
One row per result. Every row can be downloaded as JSON, CSV, Excel or HTML, or read through the API.
| Field | Label | Type | Example |
|---|---|---|---|
index | # | number | 0 |
file_url | File | URL | https://api.apify.com/v2/key-value-stores/LCqVWrkEdfnbldvyA/records... |
filename | File name | text | image.png |
mime | Type | text | image/png |
bytes | Bytes | number | 5844 |
credits | Credits | number | 3 |
ms | Time (ms) | number | 2912 |
file_key | file_key | text | result-001-image.png |
width | width | number | 600 |
height | height | number | 200 |
format | format | text | png |
blocked_requests | blocked_requests | number | 0 |
truncated | truncated | true/false | false |
Real rows from a run of the Actor (fields that name people are left out):
[ { "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 } ] No code: run it on the Apify Store
- Open the HTML to image API page on Apify.
- Fill in the input form. An example input is already filled in.
- Press Start, wait for the run to finish, and download the results as JSON, CSV or Excel from the Output tab.
The input that is pre-filled on the Actor page:
{ "html": "<div style='font:700 48px sans-serif;padding:40px;background:#1fa37a;color:#fff'>Hello, vøiddo</div>", "width": 600, "height": 200 } Ready-made examples
Saved inputs on Apify: run one as it is, or copy it and change the values.
Python (apify-client)
Get your API token in Apify Console under Settings, then Integrations. The Actor id is v0iddo/html-to-image.
from apify_client import ApifyClient client = ApifyClient("YOUR_APIFY_TOKEN") run_input = {'html': "<div style='font:700 48px " "sans-serif;padding:40px;background:#1fa37a;color:#fff'>Hello, " 'vøiddo</div>', 'width': 600, 'height': 200} run = client.actor("v0iddo/html-to-image").call(run_input=run_input) for item in client.dataset(run["defaultDatasetId"]).iterate_items(): print(item) cURL
curl -X POST "https://api.apify.com/v2/acts/v0iddo~html-to-image/run-sync-get-dataset-items" \ -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øiddo</div>", "width": 600, "height": 200}' Price
$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.
FAQ
What data does the HTML to image API return?
Each result is one row in an Apify dataset. Fields include index, file_url, filename, mime, bytes, credits, ms, file_key, and more. The table above shows every field with an example value.
Can I use it without writing code?
Yes. Open the Actor page on Apify, fill in the input form (an example is already filled in), press Start, and download the results as JSON, CSV, Excel or HTML. You can also schedule runs there.
How much does it cost?
$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. A new Apify account gets $5 of platform credit every month.
Links
- Actor on the Apify Store: HTML to image API
- Full guide with every field and the JavaScript example: https://voidd0.github.io/html-to-image/
- Step by step: https://voiddo.com/export/html-to-image/