One requests.post() call. Returns PNG bytes. Works with Django, Flask, FastAPI — and any Python script.
Selenium is the heavy option. wkhtmltopdf is the abandoned option. Neither deploys cleanly.
Sync with requests, async with httpx — same API, same result.
import requests
def html_to_png(html: str) -> bytes:
resp = requests.post(
"https://api.renderpix.dev/v1/render",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
},
json={
"html": html,
"width": 1200,
"height": 630,
"format": "png",
},
timeout=30,
)
resp.raise_for_status()
image_url = resp.json()["url"]
return requests.get(image_url).content
# Usage
png_bytes = html_to_png("<h1 style='font-size:80px'>Hello</h1>")
with open("output.png", "wb") as f:
f.write(png_bytes)
requests for sync code or httpx for async. No SDK required.How the common Python HTML-to-image options compare on the things that matter in production.
| Tool | Installation | Deploys on serverless | Modern CSS | Output formats | Actively maintained |
|---|---|---|---|---|---|
| RenderPix | pip not needed | Yes | Full support | PNG, JPEG, WebP | Yes |
| Selenium + Chrome | ChromeDriver + Xvfb | No | Full support | PNG only | Yes |
| wkhtmltopdf | System binary | With effort | No grid/flex | PNG, PDF | Abandoned |
| imgkit (wkhtmltopdf wrapper) | wkhtmltopdf required | With effort | No grid/flex | PNG, JPEG, PDF | Minimal |
Yes. RenderPix is a plain HTTP API — any framework that can make an outbound HTTP request works. Use requests in Django or Flask views, httpx in FastAPI or async Django, or the stdlib urllib if you have no dependencies. A Django example is in the code tab above.
Yes. Use httpx.AsyncClient for fully async code — compatible with FastAPI, async Django views, and standalone asyncio. See the "httpx (async)" tab in the code example above. The API itself is stateless, so you can fire multiple concurrent render requests without any extra configuration.
wkhtmltopdf uses a patched WebKit build from 2012 that lacks CSS Flexbox, CSS Grid, custom fonts via @font-face, and most modern CSS. It's also been effectively abandoned — the last meaningful release was 2020 and the maintainers actively recommend against new usage. RenderPix uses real headless Chrome, so your templates render exactly as they do in a browser.
Yes. Because RenderPix is an API call rather than a local binary, your Lambda function just makes an outbound HTTPS request. No binary layer needed, no container size limit to worry about. Works on Lambda, Cloud Run, App Engine, Fly.io, Railway, and any serverless Python environment.
Free tier: 100 renders per month, no credit card required. Starter is $9/month for 2,000 renders. For batch jobs or high-volume pipelines, check the pricing page — volume plans are available and cost significantly less per render than running your own Selenium infrastructure on EC2.
No binaries, no display servers, no DevOps. Free tier, no credit card required.