# HTML to image API

> POST HTML and CSS to https://render.cuelark.com/v1/screenshot with the html field and a viewport size, and get back a PNG, JPEG or WebP image of it.

URL: https://render.cuelark.com/html-to-image-api

## Request
```bash
curl -X POST https://render.cuelark.com/v1/screenshot \
  -H "content-type: application/json" \
  -d '{"html":"<h1 style=\"font:64px system-ui\">Hello</h1>","width":1200,"height":630,"format":"png"}' \
  -o card.png
```

## HTML image or the built-in card?
For simple title-and-description cards, the /v1/og endpoint is faster, takes no browser time and isn't metered. Use HTML to image when you need your own layout, images, web fonts or CSS effects.

## Tips
- Set width and height to the image size you want, and make the body fill 100vh.
- Use absolute URLs for images and fonts.
- Set "retina": true for 2x pixels on high-DPI screens.

## FAQ
### Can I use Tailwind or Google Fonts?
Yes. Load them with a <script> or <link> tag in your HTML. Any public CDN works.

### Is it the same quota as screenshots?
Yes. HTML to image is a screenshot of your HTML, so it counts as one browser render.
