HTML to image API — render HTML and CSS to PNG or JPEG
Renders your own HTML (and optional CSS) in Chromium and returns an image. Because it’s a real browser, CSS grid, flexbox and web fonts work.
POST https://api.shotvik.com/v1/htmlContent-Type: application/jsonAuthorization: Bearer <api_key>Request body (JSON)
Section titled “Request body (JSON)”Unknown fields are rejected with 400 invalid_request.
| Field | Type | Default | Description |
|---|---|---|---|
html |
string, required | The HTML to render. html and css together may be at most 1,048,576 bytes (measured in bytes, after the CSS is added as a <style> element). External resources (fonts, images, CSS) are loaded through the same safety checks as URL screenshots. |
|
css |
string | Optional CSS, added as a <style> element in front of your HTML. It counts toward the same 1,048,576-byte limit as html. |
|
format |
png · jpeg |
png |
Output format. PDF from HTML isn’t offered in v1. |
width |
integer, 100–3840 | 1280 |
Viewport width in CSS pixels. |
height |
integer, 100–3840 | 800 |
Viewport height in CSS pixels. |
full_page |
boolean | false |
Capture the full page, capped at 16,384 px height and 50 megapixels. |
device_scale_factor |
number, 1–3 | 1 |
Pixel density. |
jpeg_quality |
integer, 1–100 | 80 |
Only with format: "jpeg". |
wait_until |
load · domcontentloaded · networkidle · commit |
load |
Event to wait for before capturing. |
delay_ms |
integer, 0–10000 | 0 |
Extra wait after load; counts toward the 30-second render timeout. |
dark_mode |
boolean | false |
Emulate prefers-color-scheme: dark. |
cache |
boolean | false |
Opt-in cache on our Hetzner servers. Cache hits don’t count toward your quota. |
cache_ttl |
integer, 60–2592000 | 86400 |
Cache lifetime in seconds (max 30 days, provisional). Only with cache: true. |
Response
Section titled “Response”200 with Content-Type image/png or image/jpeg. Response headers are the same as for Screenshot a URL, except X-Target-Status, which only applies to URL renders.
Errors: see Errors. Possible statuses: 400, 401, 403, 413, 429, 500, 503, 504.
Example
Section titled “Example”curl https://api.shotvik.com/v1/html \ -H "Authorization: Bearer $SHOTVIK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"html": "<h1>Hello</h1>", "css": "h1 { font: 64px sans-serif; }", "width": 800, "height": 400}' \ --fail-with-body --output hello.png- External resources referenced in your HTML go through the same checks and limits as URL screenshots: only public
http(s)addresses on ports 80 and 443, and a budget of 25 MiB and 400 requests per render. Blocked resources, or resources beyond the budget, are dropped and the render continues. Skipped fonts and images are listed in theX-Shotvik-Warningsheader. - For Open Graph images with templates and signed public links, use OG images.
Shotvik is in private beta. Request access: support@shotvik.com · Privacy