---
title: "Parameters Reference"
description: "Full reference for every parameter accepted by the html2img HTML and Screenshot APIs."
url: "https://html2img.com/docs/parameters/"
---

# API Parameters

This page provides an overview of all available parameters for both the HTML/CSS API and Screenshot API. Click on any parameter to see detailed examples and usage information.

## HTML/CSS API Parameters

### Required Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| [`html`](https://html2img.com/docs/parameters/html/) | string | The HTML content to render. Can include inline CSS and JavaScript. |

### Optional Parameters

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| [`css`](https://html2img.com/docs/parameters/css/) | string | null | Additional CSS to inject into the page. Useful for keeping styles separate from HTML. |
| [`width`](https://html2img.com/docs/parameters/dimensions/) | integer | 1440 | Viewport width in pixels. Must be between 1 and 5000. |
| [`height`](https://html2img.com/docs/parameters/dimensions/) | integer | 900 | Viewport height in pixels. Must be between 1 and 5000. |
| [`fullpage`](https://html2img.com/docs/parameters/fullpage/) | boolean | false | When true, captures the full page height regardless of viewport height. |
| [`dpi`](https://html2img.com/docs/parameters/dpi/) | integer | 2 | Device pixel ratio for the capture, between 1 and 4. Higher values increase resolution but also processing time. |
| [`webhook_url`](https://html2img.com/docs/parameters/webhook-url/) | string | null | URL to receive a JSON callback with the image URL when the render finishes. Recommended for larger images or higher DPI values. |
| [`ms_delay`](https://html2img.com/docs/parameters/ms_delay/) | integer | null | Adds a delay (in milliseconds) before capturing the image, between 1 and 5000. Useful for animations and dynamic content. |
| [`wait_for_selector`](https://html2img.com/docs/parameters/wait_for_selector/) | string | null | Waits for a specific CSS selector to be present before capturing. Note: does not work with iframe content. |
| [`format`](https://html2img.com/docs/parameters/format/) | string | png | Output format: `png` for an image or `pdf` for an A4 document with selectable text. |
| [`scale_to_fit`](https://html2img.com/docs/parameters/scale-to-fit/) | boolean | false | PDF only. Scales content wider than the A4 page to fit the page width and trims trailing blank pages. |

## Screenshot API Parameters

### Required Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| [`url`](https://html2img.com/docs/parameters/url/) | string | The URL to capture. Must be a valid, publicly accessible URL. |

### Optional Parameters

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| [`css`](https://html2img.com/docs/parameters/css/) | string | null | Additional CSS to inject into the page. Useful for modifying the page appearance. |
| [`width`](https://html2img.com/docs/parameters/dimensions/) | integer | 1440 | Viewport width in pixels. Must be between 1 and 5000. |
| [`height`](https://html2img.com/docs/parameters/dimensions/) | integer | 900 | Viewport height in pixels. Must be between 1 and 5000. |
| [`fullpage`](https://html2img.com/docs/parameters/fullpage/) | boolean | false | When true, captures the full page height regardless of viewport height. |
| [`selector`](https://html2img.com/docs/parameters/selector/) | string | null | CSS selector to capture a specific element instead of the full page. Maximum 255 characters. |
| [`dpi`](https://html2img.com/docs/parameters/dpi/) | integer | 1 | Device pixel ratio for the capture, between 1 and 4. Higher values increase resolution but also processing time. |
| [`webhook_url`](https://html2img.com/docs/parameters/webhook-url/) | string | null | URL to receive a JSON callback with the image URL when the render finishes. Recommended for screenshots. |
| [`ms_delay`](https://html2img.com/docs/parameters/ms_delay/) | integer | null | Adds a delay (in milliseconds) before capturing the image, between 1 and 5000. Useful for animations and dynamic content. |
| [`wait_for_selector`](https://html2img.com/docs/parameters/wait_for_selector/) | string | null | Waits for a specific CSS selector to be present before capturing. Note: does not work with iframe content. |
| [`format`](https://html2img.com/docs/parameters/format/) | string | png | Output format: `png` for an image or `pdf` for an A4 document with selectable text. |
| [`scale_to_fit`](https://html2img.com/docs/parameters/scale-to-fit/) | boolean | false | PDF only. Scales content wider than the A4 page to fit the page width and trims trailing blank pages. |

> **Important**
>
> When using the Screenshot API, we strongly recommend using the `webhook_url` parameter due to unpredictable page load times. See the [webhook_url documentation](https://html2img.com/docs/parameters/webhook-url/) for more details.

> **Warning**
>
> Higher DPI values (2-4) significantly increase processing time and memory usage. For most use cases, a DPI of 1 provides sufficient quality. See the [DPI documentation](https://html2img.com/docs/parameters/dpi/) for more details.

The [Templates API](https://html2img.com/docs/templates/) also accepts `format` and `scale_to_fit` alongside each template's own inputs.

## Validation errors

An invalid parameter returns HTTP `400` with a `validation_error` envelope naming the field and the rule that failed (the Templates API returns `422` instead):

```json
{
    "error": "Validation failed",
    "code": "validation_error",
    "details": {
        "width": ["The width field must not be greater than 5000."]
    }
}
```
