Technical Specs
API Reference.
The Endpoint
POST
https://html2png.dev/api/convertThe primary endpoint for converting HTML to high-quality images or PDFs.
Parameters
| Param | Type | Default | Description |
|---|---|---|---|
html* In: Body | String | The raw HTML string to be rendered. Send as raw body with Content-Type: text/html. | |
width In: Query | Integer | 1200 | Width of the viewport in pixels. |
height In: Query | Integer | 630 | Height of the viewport in pixels. |
format In: Query | String | png | Output format. Options: png, jpeg, webp, pdf. |
deviceScaleFactor In: Query | Integer | 1 | Device scale factor (Retina scaling). Ranges from 1 to 4. |
delay In: Query | Integer | 0 | Time in milliseconds to wait before taking the screenshot. |
zoom In: Query | Float | 1.0 | Viewport zoom level. Ranges from 0.1 to 3.0. |
omitBackground In: Query | Boolean | false | Whether to hide the default white background and allow transparency. |
selector In: Query | String | null | A CSS selector to wait for before taking the screenshot. |
colorScheme In: Query | String | light | Forces light or dark color scheme. Options: light, dark. |
persist In: Query | Boolean | true | Whether 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
POST
https://html2png.dev/api/screenshotCapture screenshots of websites with customizable options like viewport size, format, and more.
Parameters
| Param | Type | Default | Description |
|---|---|---|---|
url* In: Body/Query | String | The URL of the website to screenshot. | |
width In: Query | Integer | 1200 | Width of the viewport in pixels. |
height In: Query | Integer | 630 | Height of the viewport in pixels. |
format In: Query | String | png | Output format. Options: png, webp, pdf. |
deviceScaleFactor In: Query | Float | 1 | Device scale factor (Retina scaling). |
delay In: Query | Integer | 0 | Time in milliseconds to wait before taking the screenshot. |
omitBackground In: Query | Boolean | false | Whether to hide the default white background and allow transparency. |
colorScheme In: Query | String | light | Forces light or dark color scheme. Options: light, dark. |
fullPage In: Query | Boolean | false | Whether to capture the full page or just the viewport. |
userAgent In: Query | String | null | Custom user agent to use for the request. |
persist In: Query | Boolean | true | Whether 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