Python · HTML to Image

Convert HTML to Image in Python

Use the renderpix REST API from Python to turn any HTML template into a pixel-perfect image — no headless browser, no Puppeteer, no servers to manage.

Pythonrenderpix API example
import requests

html_template = """
<div style="padding:48px;background:#0f172a;color:white;font-family:sans-serif;
           border-radius:12px;width:800px">
  <h1 style="font-size:36px">Order Confirmed</h1>
  <p style="color:#94a3b8">Your order #INV-2026-042 is confirmed.</p>
</div>
"""

response = requests.post(
    "https://renderpix.dev/v1/render",
    headers={"X-API-Key": "rpx_your_key"},
    json={
        "html": html_template,
        "width": 800,
        "height": 400,
        "format": "png",
    },
)

with open("output.png", "wb") as f:
    f.write(response.content)

print(f"Done. Size: {len(response.content) / 1024:.1f} KB")

Common use cases

📧
Email headers
Generate branded email header images from HTML templates.
📊
Report exports
Export data visualizations and report summaries as images.
🔖
PDF thumbnails
Create preview thumbnails for PDF documents.
🤖
Automated pipelines
Integrate into Django, Flask, or FastAPI workflows.

Start converting HTML to images for free

100 free renders/month. No credit card. Set up in 2 minutes.

Get free API key