# html2image: Convert HTML String or URL to an Image

> html2image (Convert HTML String or URL to an Image) is a 1001fx API function in the group Images: POST https://api.1001fx.com/images/html2image, 5 credits per item. It works as a ready-made module in Make and n8n or as a plain HTTP call.

Converts an HTML string or URL to an image. If an HTML string is given. Replacements for the text are processed. It is also possible to use Tailwind in classes.

- Group: Images
- Endpoint: `POST https://api.1001fx.com/images/html2image`
- Authentication: header `X-API-KEY: YOURSECRETAPIKEY`
- Content type: application/json
- Credits: 5 credits per item
- Ready-made in: Make and n8n
- Docs: https://1001fx.com/functions/html2image

## Parameters

- `html` (string, optional) – HTML: HTML to render as an image. You can use tailwind classes provided in a tw tag in your elements. The following font families are supported: Alegreya, Barlow, Inter, Lato, Montserrat, OpenSans, Oswald, Poppins, PTSans, Raleway, Roboto
- `url` (string, optional) – URL: URL to render as an image.
- `fullPage` (boolean, optional) – Screenshot Full Page: Specifies if the whole page should be saved in the screenshot. Defaults to false.
- `outputFormat` (enum, required, one of `png`, `jpeg`) – Output Format: The desired output format
- `width` (number, optional) – Width: The desired output width.
- `height` (number, optional) – Height: The desired output height.
- `replacements` (array<object>, optional) – Replacements: Key Value pairs to replace in your provided html.
  - `key` (string, required) – Key: Replacement key to search for in your html. Must be provided in the pattern {{KEY}}.
  - `value` (string, required) – Value: Replacement value to replace in your html.

## Example: HTML to PNG

```bash
curl -X POST 'https://api.1001fx.com/images/html2image' \
  -H 'X-API-KEY: YOURSECRETAPIKEY' \
  -H 'Content-Type: application/json' \
  -d '{"height":600,"width":800,"outputFormat":"png","html":"<div class='\''flex flex-1 bg-gray-300 rounded-md'\''><div class='\''flex flex-col md:flex-row w-full py-12 px-4 md:items-center justify-between p-8'\''><h2 class='\''flex flex-col text-3xl sm:text-4xl font-bold tracking-tight text-gray-900 text-left'\''><span>Hello {{ name }}</span><span class='\''text-indigo-600'\''>Welcome to 1001fx</span></h2><div class='\''mt-8 flex md:mt-0'\''><div class='\''flex rounded-md '\''><div class='\''flex items-center justify-center rounded-md border-transparent bg-indigo-600 px-5 py-3 text-base font-medium text-white'\''>Get started</div></div><div class='\''ml-3 flex rounded-md '\''><div class='\''flex items-center justify-center rounded-md border-transparent bg-white px-5 py-3 text-base font-medium text-indigo-600'\''>Learn more</div></div></div></div></div>"}'
```
