HTML to Image API reference

Take a picture of a web page or your own HTML code
API reference
Advanced
1 min read
Updated Nov 27, 2026
POST /v1/render/html-to-image

Take a picture of a web page or your own HTML code

POST /v1/render/html-to-image

Guides

What it does

HTML is the code that web pages are made of. This tool shows your HTML code, or a public web page, in a hidden browser and takes a picture of it, like a screenshot. You can set the size, the picture format and whether to capture the whole page.

How to call it

Send a POST request to /v1/render/html-to-image with your API key in the X-Api-Key header. The parameters below go in the request body (or in the address of a GET request). Files, when the tool takes them, are sent as multipart form data. Every answer carries a Request-Id header: quote it if you contact support.

Parameters

ParameterTypeDefaultWhat it does
htmlOptionalstring—The HTML to render. Send `html`, `url` or a saved template (templateId).
cssOptionalstring—CSS appended to the document (after the saved template's own css when a templateId is used). {{variables}} in it are filled like those in the html.
widthOptionalinteger1000Viewport width (px).
min 1
heightOptionalinteger1500Viewport height (px).
min 1
formatOptionalstringpngImage format (png, jpeg, webp, avif).
pngjpegwebpavif
deviceScaleFactorOptionalnumber1Device pixel ratio.
1 to 3
clipOptionalobject—Crop region within the rendered viewport.
waitForSelectorOptionalstring—Wait until this CSS selector appears (at most 10 s).
waitForMillisecondsOptionalinteger—Extra wait before capture (ms).
0 to 10000
waitUntilOptionalstring—Navigation milestone to wait for.
loaddomcontentloadednetworkidle0networkidle2
mediaTypeOptionalstring—CSS media type.
screenprint
colorSchemeOptionalstring—prefers-color-scheme.
lightdarkno-preference
timezoneOptionalstring—IANA timezone, e.g. America/New_York.
localeOptionalstring—BCP-47 locale, e.g. en-US.
headersOptionalobject—Extra request headers per host: { "host[:port]": { "Header": "value" } } (max 10 hosts, 20 headers per host, names up to 200, values up to 4000 chars; Host cannot be overridden). Applied only to requests to that host.
cookiesOptionalarray—Cookies (max 20). A cookie needs domain or url; domains that are localhost/private or fail DNS resolution are rejected.
jpegQualityOptionalinteger—Quality 1-100 for jpeg, webp and avif.
1 to 100
urlOptionalstring—Render this public web page instead of `html` (send one of the two). Only http/https on ports 80 and 443; private, internal and cloud-metadata addresses are refused (400 url_blocked), every redirect and every resource the page loads goes through the same check. Can be switched off per plan or server-wide.
deviceOptionalstring—Device preset: sets the viewport, pixel ratio, user agent and touch emulation. Explicit width / height / deviceScaleFactor / userAgent win over the preset.
iphone-seiphone-14iphone-14-pro-maxpixel-7galaxy-s20ipadipad-proandroid-tabletlaptopdesktop
userAgentOptionalstring—User-Agent header the page is loaded with (single line, max 300 characters).
blockResourcesOptionalarray—Resource types the page may not load: image, stylesheet, script, font, media, xhr, fetch, websocket, other. The main document is never blocked.
waitForFunctionOptionalstring—JavaScript expression evaluated in the page until it is truthy (at most 10 s), e.g. `window.chartReady === true`. Runs with the same rights as the page own scripts.
langOptionalstring—Document language (BCP-47, e.g. ja, zh-Hans, ar). Sets <html lang> and the Accept-Language header so the right font variant and shaping are used for CJK, Arabic and Indic text.
fontsOptionalarray—Web fonts to use in the page: [{ family, data (base64 TTF/OTF/WOFF/WOFF2), weight, style }] (max 8, 3 MB each). They are embedded as data: URIs; fonts can never be loaded by a remote address.
variablesOptionalobject—Values for {{name}} / {{a.b}} placeholders in the html, the css or the saved template (one document). Values are HTML-escaped in the page; a value used as a whole link (src, href, CSS url()) must be an http(s) address or an image data: URI; a value used inside css cannot contain braces, semicolons, quotes, angle brackets, backslashes or comments. There is no expression language, so a value can never become markup or script. Max 200 values, strings up to 20,000 characters.
templateIdOptionalstring—Render a saved template instead of sending html (create one with POST /v1/templates). The template supplies the html and css; fill its {{variables}} with `variables` (one document) or `records` (one document per record). Send templateId or html, not both; it cannot be combined with markdown, text or url. Requires an individual customer API key.
recordsOptionalarray—One object of variable values per document: the answer has one result per record (a image each) instead of one url. Send records or variables, not both; it cannot be combined with url. How many records one request may carry, and how they count toward the quota, is set per plan.
transparentOptionalbooleanfalseKeep the page background transparent (png, webp, avif).
fullPageOptionalbooleanfalseCapture the whole scrollable page instead of the viewport/body. Bounded by the plan pixel budget (400 render_size_exceeded). Cannot be combined with clip or selector.
selectorOptionalstring—Capture only the element matching this CSS selector (400 when nothing matches). Cannot be combined with clip or fullPage.
scrollToOptionalstring—Scroll before the capture: "top", "bottom" (steps down so lazy-loaded content loads), a pixel offset, or a CSS selector to bring into view.
validate_onlyOptionalbooleanfalsetrue = check the request without running it. The answer is `{ validated: true, valid, errors[], files, estimate, limits }` instead of the endpoint's usual answer: `errors` lists every parameter or file the real call would reject, `estimate` is what it would count against your plan, and `limits` are the limits that apply to this endpoint for your key. Nothing is processed, no files are produced and no files are counted against the plan; the call itself counts as one request. The tool’s own checks run on it too, up to the point where processing would start; a problem that only shows while processing (a crop outside the image) is not found. Files given as a web address are not downloaded.
presetIdOptionalstring—Apply a saved preset (create one with POST /v1/presets). Every value stored in the preset is used unless this request sets that field itself. The preset must have been saved for this same endpoint; requires an individual customer API key.
responseOptionalstringurlHow the result comes back. url (default) = the usual JSON answer with a signed URL per file. binary = the file itself as the HTTP body with Content-Type and Content-Disposition (a request with several result files returns one zip). base64 = the JSON answer with each result carrying `data` (base64) and `mimeType` instead of `url`, up to 20 MB in total. Answers without a result file are returned as JSON either way. Not available together with `async: true`.
urlbinarybase64
filenameOptionalstring—The name for the result file (without extension; the extension follows the format). Used as the download name: Content-Disposition for response=binary, `downloadName` in the JSON answer otherwise. Path separators, control and bidirectional characters and Windows-reserved characters are removed; names are capped at 150 bytes. Several result files get -1, -2 ... added.
filename_templateOptionalstring—A name built per result file from placeholders: {name} (the input file name without extension), {index} (1, 2, ...), {date} (YYYY-MM-DD), {time} (HH-MM-SS, UTC), {format} (the result extension) and {operation}. Example: "{name}-{index}-{date}". Sanitised like filename; result files that would get the same name are numbered -2, -3 ... Not together with filename.
appOptionalstring—The name of the app that makes this call, for example "My shop importer". It is shown in your History next to the result, so you can tell which app did what. The official apps fill it in themselves (Davix H2I plugin, Davix H2I n8n node, Davix H2I Studio, Davix H2I Dashboard); when you leave it out, the official SDKs and plugins are recognised from their User-Agent. Up to 60 characters; control characters and angle brackets are removed. The header `X-Davix-App` does the same. It is only a label: it never changes what the call does.
Idempotency-KeyOptionalstring—Optional idempotency key (8-128 characters). Reuse it for a retry of the SAME request; a different request with the same key -> 409 idempotency_key_conflict.
asyncOptionalboolean—Opt-in asynchronous execution. With async=true and an individual customer API key the endpoint answers 202 {job_id, status_url} and the result becomes available from GET /v1/jobs/{id}. Omitted/false = the normal synchronous response. A request that carries several files in one field is not run as a job: it is processed immediately, answered with one result per file, and a `warnings` entry says that async was not applied.

Use it from your code

cURL

curl -X POST "https://app.h2i.davixlabs.io/v1/render/html-to-image" \
  -H "X-Api-Key: $DAVIX_H2I_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"width":1000,"height":1500,"format":"png"}'

Node.js

const { DavixH2I } = require('@davixlabs/h2i-sdk');

const h2i = new DavixH2I({ apiKey: process.env.DAVIX_H2I_API_KEY, baseUrl: process.env.DAVIX_H2I_URL });
const result = await h2i.render.htmlToImage({
    "width": 1000,
    "height": 1500,
    "format": "png"
  });
console.log(result.data, result.requestId);

PHP

<?php
require 'vendor/autoload.php';

$h2i = new \Davix\H2I\Client(['apiKey' => getenv('DAVIX_H2I_API_KEY'), 'baseUrl' => getenv('DAVIX_H2I_URL')]);
$result = $h2i->render()->htmlToImage([
    'width' => 1000,
    'height' => 1500,
    'format' => 'png',
]);
echo $result->requestId;
Was this article helpful?
Thanks for your feedback.
ON THIS PAGE
IN THIS SECTION
NEED A HAND?
Cannot find what you need? Our team replies fast.
Contact support
Still stuck?

Talk to a human

Send us a message and we will get back to you quickly.