Python  ·  HTML to Image

HTML to Image in Python
without Selenium

One requests.post() call. Returns PNG bytes. Works with Django, Flask, FastAPI — and any Python script.

Start Free — 100 renders/mo View API Docs
The Problem

Python HTML-to-image options all have painful tradeoffs

Selenium is the heavy option. wkhtmltopdf is the abandoned option. Neither deploys cleanly.

Selenium / ChromeDriver
Requires a matching ChromeDriver binary, a display server (Xvfb on Linux), specific Chrome version pinning, and careful memory management. Getting it to run in Docker takes hours. Keeping it running in production takes weeks.
RenderPix — just a POST request
Install nothing. Send your HTML string to the API, get PNG bytes back. No binary dependencies, no display server, no version pinning. Deploys on any Python host in minutes.
wkhtmltopdf
Uses an unmaintained WebKit fork. No Flexbox, no CSS Grid, no modern CSS at all. Font rendering differs from real browsers. The project hasn't had a meaningful release since 2020 and actively discourages new use.
Real Chromium rendering
RenderPix renders with headless Chrome — the same engine your users' browsers use. Full CSS support, accurate font rendering, WebP and PNG output at any resolution. Your template looks exactly as designed.
Code Example

Works in any Python framework

Sync with requests, async with httpx — same API, same result.

requests (sync)
httpx (async)
Django view
render.py
Python 3.8+
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)
How It Works

No binaries, no servers, no surprises

01
Build your HTML string
Render a Jinja2/Django template to a string, or build HTML programmatically. Inject dynamic values — usernames, dates, scores, chart data — before sending.
02
POST to the API
One HTTP POST with your HTML, width, height, and API key. Use requests for sync code or httpx for async. No SDK required.
03
Save or stream the image
Get PNG or WebP bytes back. Save to disk, upload to S3, return from a view, or attach to an email. Any workflow that handles bytes works.
Comparison

RenderPix vs Selenium vs wkhtmltopdf

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
FAQ

Common questions

Does it work with Django and Flask?

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.

Is there async support?

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.

How is this different from wkhtmltopdf?

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.

Does it work on AWS Lambda or Google Cloud Run?

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.

What does it cost?

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.

HTML to image in Python — in under 10 minutes

No binaries, no display servers, no DevOps. Free tier, no credit card required.