Convert HTML, CSS or any URL into a PNG with a single API call.
HTML to Image is a REST API that turns raw HTML and CSS, a live URL, or a named JSON template into a PNG in seconds. Every render runs in real Chrome, so flexbox, grid, custom properties, web fonts and inline JavaScript behave exactly as they do in the browser. The first 25 renders each month are free, with no card required.
This organisation hosts the official client libraries for the API. The PHP SDK and Laravel integration are available now on Packagist. Watch or star the repos to get notified when more ship.
Send some HTML, get back a hosted PNG.
curl -X POST https://app.html2img.com/api/html \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"html": "<h1>Hello world</h1>"}'{
"success": true,
"credits_remaining": 95,
"id": "abc123",
"url": "https://i.html2img.com/abc123.png"
}Grab a key from your dashboard, then read the getting started guide and the authentication docs.
| Endpoint | Use it for | Docs |
|---|---|---|
POST /api/html |
Your own markup and CSS, full design control | html parameter |
POST /api/screenshot |
Capturing a public URL you already host | url parameter |
POST /api/v1/templates/[slug] |
A tested design, JSON in, PNG out | browse templates |
The base URL for every endpoint is https://app.html2img.com. Full parameter reference is in the docs.
- Social media images such as Open Graph cards, Twitter/X posts, Instagram squares and stories. See social templates
- Business documents such as invoices, receipts, event tickets and certificates. See business templates
- Developer assets such as code screenshots, GitHub social previews and project showcase cards. See developer templates
- URL screenshots, full page or selector cropped, with CSS injection to remove cookie banners and sticky headers before capture. See screenshot examples
There are 25 named templates in total, covering social, commerce, content and marketing.
Install the official libraries from Packagist. Anything else works over plain HTTP today.
| Language | Install | Repo | Status |
|---|---|---|---|
| PHP | composer require html2img/html2img-php |
html2img-php | Available |
| Laravel | composer require html2img/html2img-laravel |
html2img-laravel | Available |
| JavaScript and Node.js | npm | In development | |
| Python, Ruby and more | Planned |
Framework-agnostic, built on Guzzle, returns a typed response object. Requires PHP 8.3+.
use Html2img\Html2imgClient;
use Html2img\Request\HtmlRequest;
$client = new Html2imgClient('your-api-key');
$response = $client->html(new HtmlRequest(
html: '<!doctype html><html><body><h1>Hello</h1></body></html>',
width: 1200,
height: 630,
));
echo $response->url; // https://i.html2img.com/abc123def456.pngSee the PHP SDK readme and the PHP guide.
Zero-config auto-discovery, a Html2img facade, a published config file, one-line saving to any filesystem disk, and an html2img:test artisan health check. Requires Laravel 11 or 12.
use Html2img\Laravel\Facades\Html2img;
use Html2img\Request\HtmlRequest;
$response = Html2img::html(new HtmlRequest(
html: view('og.post', ['post' => $post])->render(),
width: 1200,
height: 630,
dpi: 2,
));
$path = Html2img::store($response, "og/{$post->id}.png");See the Laravel integration readme and the Laravel guide.
No sign-up needed. Build an image in the browser, then move to the API when you want to automate it.
- Open Graph Image Generator
- Code Screenshot Generator
- Invoice Image Generator
- Certificate Generator
- Twitter Card Generator
- YouTube Thumbnail Generator
- Pinterest Pin Generator
- Quote Card Generator
See the full image generation tools hub.
Worked examples for the seven languages developers reach for most. Anything that can make an HTTP request will work.
PHP · Laravel · Ruby on Rails · Python · JavaScript and Node.js · React · Vue
- Real Chrome rendering so your output matches the browser. Features
- Webhook delivery for renders that run past the 30 second sync window. webhook_url docs
- DPI control from 1x to 4x for retina output when you need it. dpi docs
- Custom fonts from Google Fonts, Adobe Fonts and self-hosted
@font-face, all server-side. - Global CDN, with images served from
i.html2img.com.
Honest, side-by-side notes against the common alternatives, covering pricing, features and migration effort.
- htmlcsstoimage alternative
- Bannerbear alternative
- Urlbox alternative
- ApiFlash alternative
- All comparisons
- How to generate signed digital certificates at scale
- Dynamic OG images in Astro, Hugo and Eleventy
- How to generate dynamic Open Graph images in Laravel
- Why
@vercel/ogfails on emoji and how to fix it - All articles
Start free with 25 renders a month and no card. Paid plans raise the render volume as you grow. See pricing.
Website · Features · Templates · Tools · Docs · Compare · Articles · Pricing · About · Contact