# Render HTML to an image with one request

> Render your own HTML, CSS or Markdown into an image or a PDF with one API request. For social cards, certificates, receipts and reports.

To turn HTML into an image, send it to CurlShot in a POST request and get back a PNG, JPEG, WebP or PDF. The HTML is rendered by a real browser, so web fonts, flexbox, grid and images work as they do on a web page. Markdown is accepted the same way. It is the simple way to make social sharing cards, certificates, receipts and reports from a template.

Page for people: https://curlshot.com/tools/html-to-image

## Steps

1. Write the HTML and CSS of the image, as you would for a web page.
2. Send it in a POST request, with the width and height you want.
3. Save the image that comes back, or let your code do it for every item.

## What people use it for

- Open Graph and social sharing cards, one per article or product
- Certificates, tickets and badges with a name filled in
- Receipts, invoices and reports as PDF
- Charts and tables as an image for an email

## The same thing with the API

```bash
curl -X POST "https://curlshot.com/api/v1/screenshot" \
  -H "X-Access-Key: YOUR_ACCESS_KEY" \
  -H "Content-Type: application/json" \
  -d '{"html":"<h1 style=\"font: 600 64px system-ui; padding: 80px\">Hello</h1>","viewport_width":1200,"viewport_height":630}' \
  --output card.png
```

An access key is free: https://curlshot.com/register. Read more:

- [HTML and Markdown input](https://curlshot.com/docs/html-and-markdown.md)
- [Open Graph images](https://curlshot.com/docs/guides/open-graph-images.md)

## Questions

### How do I convert HTML to an image?

Send the HTML to CurlShot in the html field of a POST request. The answer is the image file. Set viewport_width and viewport_height to the size the image should have.

### Can I use my own fonts and images?

Yes. The HTML is rendered like a web page, so fonts and images referenced by a public address load normally.

### Can I get a PDF instead?

Yes. Add format=pdf. Paper size, margins and orientation are options.

### Does it take Markdown?

Yes. Send a markdown field instead of html and it is rendered as a clean, styled page.

## Related

- [Web page to PDF](https://curlshot.com/tools/website-to-pdf.md): Turn a web page into a PDF document from its address. Real pages, working links and selectable text. Paste the address, nothing to install. Also an API.
- [URL to image](https://curlshot.com/tools/url-to-image.md): Convert any URL into an image file. Paste a web address and download a PNG, JPEG or WebP screenshot of the page. Free to try, and one request by API.
- [Screenshot API](https://curlshot.com/tools/screenshot-api.md): A screenshot API for developers. One HTTP request turns a URL, HTML or Markdown into a PNG, JPEG, WebP or PDF. Full page, devices, blocking, cache, MCP.
