Technical Specs

API Reference.

The Endpoint

POSThttps://html2png.dev/api/convert

The primary endpoint for converting HTML to high-quality images or PDFs.

Parameters

ParamTypeDefaultDescription
html*
In: Body
StringThe raw HTML string to be rendered. Send as raw body with Content-Type: text/html.
width
In: Query
Integer1200Width of the viewport in pixels.
height
In: Query
Integer630Height of the viewport in pixels.
format
In: Query
StringpngOutput format. Options: png, jpeg, webp, pdf.
deviceScaleFactor
In: Query
Integer1Device scale factor (Retina scaling). Ranges from 1 to 4.
delay
In: Query
Integer0Time in milliseconds to wait before taking the screenshot.
zoom
In: Query
Float1.0Viewport zoom level. Ranges from 0.1 to 3.0.
omitBackground
In: Query
BooleanfalseWhether to hide the default white background and allow transparency.
selector
In: Query
StringnullA CSS selector to wait for before taking the screenshot.
colorScheme
In: Query
StringlightForces light or dark color scheme. Options: light, dark.
persist
In: Query
BooleantrueWhether to store the image and return a public URL. If false, image is still generated but not saved.

Example Request

cURL

Success Response

JSON Output

Error Codes

400Bad Request

Missing HTML content or invalid parameters.

429Too Many Requests

Rate limit exceeded.

500Internal Server Error

Browser rendering engine failed.

Screenshot API

Endpoint

POSThttps://html2png.dev/api/screenshot

Capture screenshots of websites with customizable options like viewport size, format, and more.

Parameters

ParamTypeDefaultDescription
url*
In: Body/Query
StringThe URL of the website to screenshot.
width
In: Query
Integer1200Width of the viewport in pixels.
height
In: Query
Integer630Height of the viewport in pixels.
format
In: Query
StringpngOutput format. Options: png, webp, pdf.
deviceScaleFactor
In: Query
Float1Device scale factor (Retina scaling).
delay
In: Query
Integer0Time in milliseconds to wait before taking the screenshot.
omitBackground
In: Query
BooleanfalseWhether to hide the default white background and allow transparency.
colorScheme
In: Query
StringlightForces light or dark color scheme. Options: light, dark.
fullPage
In: Query
BooleanfalseWhether to capture the full page or just the viewport.
userAgent
In: Query
StringnullCustom user agent to use for the request.
persist
In: Query
BooleantrueWhether to store the image and return a public URL. If false, image is still generated but not saved.

Example Request

cURL

Success Response

JSON Output