Turn HTML into an image with an API (social cards, invoices, certificates)
Send HTML and CSS, get back a PNG, WebP or PDF. Generate Open Graph images, invoices and certificates without running a browser yourself.
Many apps need images they design themselves: Open Graph cards for each blog post, a certificate with the user's name, a chart for an email. Writing them in HTML and CSS is easy. Rendering them needs a browser. ScreenAPI renders the HTML you send.
Example: an Open Graph image (1200 × 630)
const html = `
<html><body style="margin:0;width:1200px;height:630px;display:flex;align-items:center;
justify-content:center;background:#111;color:#fff;font:64px system-ui">
How we cut our build time in half
</body></html>`;
const res = await fetch("https://getscreenapi.com/api/v1/screenshot", {
method: "POST",
headers: { "x-api-key": process.env.SCREENAPI_KEY, "content-type": "application/json" },
body: JSON.stringify({ html, width: 1200, height: 630, format: "png" }),
});Tips
- Send either
urlorhtml, not both. HTML can be up to 2 MB. - Web fonts and images referenced by absolute URLs are loaded normally.
- Use
format: "pdf"for invoices and documents (A4, backgrounds printed). - Use
omit_background: truewith PNG or WebP for a transparent background. - Add
cache_ttlso the same card is generated once and then served for free.
Try HTML rendering on the free plan.
Get a free key