HTML to Image API
Send raw HTML & CSS, get back a pixel-perfect PNG, JPEG, or WebP image. Generate dynamic social cards, certificates, invoices, and banners — all via a simple REST API.
Simple as a POST request
curl -X POST https://goscreenapi.com/api/v1/html-to-image \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"html": "<div style=\"background:#6d28d9;color:#fff;padding:60px;font-family:sans-serif;font-size:48px;font-weight:bold\">Hello World</div>",
"format": "png",
"width": 1200,
"height": 630
}' \
--output image.png
curl -X POST https://goscreenapi.com/api/v1/html-to-image \ -H "X-API-Key: YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{"html":"<h1>Hello</h1>","format":"png","width":1200,"height":630}' \ --output image.png$response = Http::withHeaders(['X-API-Key' => 'YOUR_KEY']) ->post('https://goscreenapi.com/api/v1/html-to-image', [ 'html' => '<h1 style="color:purple">Hello</h1>', 'format' => 'png', 'width' => 1200, 'height' => 630, ]); file_put_contents('image.png', $response->body());const res = await fetch('https://goscreenapi.com/api/v1/html-to-image', { method: 'POST', headers: { 'X-API-Key': 'YOUR_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ html: '<h1>Hello</h1>', format: 'png', width: 1200, height: 630 }), }); const buffer = await res.arrayBuffer(); fs.writeFileSync('image.png', Buffer.from(buffer));import requests r = requests.post('https://goscreenapi.com/api/v1/html-to-image', headers={'X-API-Key': 'YOUR_KEY'}, json={'html': '<h1>Hello</h1>', 'format': 'png', 'width': 1200, 'height': 630}) open('image.png', 'wb').write(r.content)
Everything you need
Full HTML & CSS support
Flexbox, Grid, custom fonts, gradients, shadows — rendered by real Chromium.
Custom viewport size
Set any width and height. Perfect for social cards (1200×630), banners, or certificates.
CSS injection
Inject additional CSS on top of your HTML without modifying the source.
Wait for selector
Wait for a specific CSS selector to appear before capturing — great for dynamic content.
Dark mode
Render with prefers-color-scheme: dark to capture dark-mode designs.
Sync & async modes
Get the image immediately (sync) or use async mode with a webhook for large batches.
PDF output
Set format=pdf to get a PDF instead of an image. Useful for invoices and reports.
Secure & isolated
Each render runs in an isolated Chromium context. No data is stored after rendering.
API Reference
https://goscreenapi.com/api/v1/html-to-image
| Parameter | Type | Default | Description |
|---|---|---|---|
html
* |
string | — | Required. Raw HTML string to render. |
format
|
string | png | Output format: png · jpeg · webp · pdf |
width
|
integer | 1280 | Viewport width in pixels (max 3840) |
height
|
integer | 800 | Viewport height in pixels (max 2160) |
selector
|
string | null | CSS selector to capture (crops to element bounds) |
wait_for
|
string | null | Wait for this CSS selector before capturing |
inject_css
|
string | null | Additional CSS to inject into the page |
dark_mode
|
boolean | false | Enable prefers-color-scheme: dark |
async
|
boolean | false | Return job ID instead of image (use with webhook_url) |
webhook_url
|
string | null | POST result to this URL when async render completes |
Response
// Async mode — returns JSON
{
"status": "queued",
"job_id": "job_abc123",
"estimated_seconds": 3
}
// Webhook payload (async complete)
{
"job_id": "job_abc123",
"status": "completed",
"image_url": "https://cdn.goscreenapi.com/html/...",
"duration_ms": 1240
}
What people build with it
Dynamic Social Cards
Generate unique OG images for every blog post, product, or user profile — automatically.
Certificates & Badges
Issue personalized completion certificates or achievement badges as downloadable images.
Invoice PDFs
Render HTML invoice templates to PDF with pixel-perfect typography and layout.
Ad Banners
Generate hundreds of ad creatives from a single HTML template with dynamic data.
Report Snapshots
Capture chart.js or D3 visualizations as static images for email reports.
Personalized Cards
Birthday cards, discount vouchers, or event invitations — all generated on the fly.
How we compare
| Feature | GoScreenAPI | Bannerbear | Placid |
|---|---|---|---|
| Raw HTML input | |||
| CSS injection | |||
| PDF output | |||
| Async + webhook | |||
| Free tier | |||
| No template required | |||
| Custom viewport | |||
| Dark mode support |
Start converting HTML to images
250 free renders per month. No credit card required. Works with any language or framework.
Transform HTML to Images
Our HTML to image API provides a powerful solution for converting raw HTML and CSS into rendered images like PNG, JPEG, or WebP. This service supports full CSS3 features, including flexbox, grid, and custom fonts. You can expect a response time of less than 500ms, ensuring efficient processing. File sizes typically range between 100KB to 300KB, depending on content complexity. Whether generating certificates or email signatures, the API delivers reliable results.
Handling viewport configuration is straightforward. Adjust it to fit your needs, whether generating a social card preview or a detailed invoice. The API allows any standard viewport size, providing great flexibility.
Flexible Format Support
Our system accepts HTML and CSS input and outputs images in multiple formats, including PNG, JPEG, and WebP. Users can specify image dimensions and choose web-optimized formats for faster loading times. By supporting CSS3, the API handles modern layout techniques effortlessly. This includes flexbox and grid systems, allowing precise control over design.
Need to render dynamic content? The API processes HTML to PNG swiftly. With built-in custom font support, your brand's identity remains consistent across all visuals. Convert HTML to images accurately, maintaining the original look and feel.
Practical Use Cases
- Generate personalized certificates with accurate styling
- Create detailed invoices for clients with custom branding
- Produce eye-catching social media cards from HTML input
- Develop email signatures that match corporate design guidelines
Technical Specifications
Under the hood, the HTML to image API supports robust configurations. Image resolutions up to 300 DPI ensure print-quality outputs if necessary. When rendering HTML as an image, the API processes up to 5MB of data per request, accommodating complex designs. It efficiently converts CSS to image, supporting media queries and pseudo-elements.
The API's HTML screenshot capabilities make it ideal for applications needing precise visual captures. A single API call can convert HTML to image formats without losing quality, thanks to advanced rendering engines.
Explore API Possibilities
Utilizing our HTML to image API, developers gain a powerful tool for visual content generation. Achieve seamless integration into existing workflows, enhancing productivity and output quality. Start transforming your HTML designs into high-quality images today!
Frequently Asked Questions
How do I convert HTML to image using your API?
To convert HTML to an image, send a POST request to our API with your HTML content. The output format can be either PNG or JPEG, with a maximum resolution of 1920x1080 pixels. The response time is typically under 2 seconds, depending on server load.
Does your API support CSS rendering for HTML to image conversion?
Yes, our API fully supports CSS rendering, allowing you to apply styles to your HTML before conversion. Inline styles, linked stylesheets, and embedded CSS are all processed to ensure accurate rendering in the output image.
Can I generate SSL certificates for my domain through your service?
Our service does not offer SSL certificate generation, as it focuses on image and content rendering. For SSL certificates, we recommend using dedicated certificate authorities that specialize in that area.
How do I create social cards with your API?
To create social cards, provide your HTML template along with meta tags for Open Graph or Twitter Cards. Our API generates a shareable image formatted as PNG, suitable for social media previews, within seconds.