Convert HTML to PDF with curl
Render HTML to PDF from the command line with one curl call. Works anonymously — an API key raises the rate limit. Full request and limits.
Last updated
| Endpoint | POST /v1/render (JSON: html required, filename optional) |
|---|---|
| Anonymous calls | allowed, rate-limited per IP (10/minute) |
| Limits | 2 MiB of HTML, 50 pages, 20 s render timeout |
The whole API is one endpoint: POST /v1/render takes a JSON body
with your HTML and streams back the PDF. No SDK required — it works from a
terminal in one command, with or without an API key:
curl -X POST https://api.pdfrender.dev/v1/render \
-H 'Content-Type: application/json' \
-d '{"html": "<h1>Hello</h1><p>Rendered by pdfrender.</p>", "filename": "hello.pdf"}' \
-o hello.pdf
html is a complete HTML string; filename (optional, default
document.pdf) sets the download filename in the Content-Disposition
header. The response is application/pdf bytes — -o writes them straight
to disk.
With an API key
Add the key as a header. A valid key lifts you from the anonymous per-IP limit to your plan's budget and meters one credit per render:
curl -X POST https://api.pdfrender.dev/v1/render \
-H 'Content-Type: application/json' \
-H 'X-API-Key: YOUR_KEY' \
-d @request.json \
-o out.pdf
A missing or invalid key is not an error — the call simply stays anonymous.
Inline images, fonts and CSS as data: URIs; external http(s) resources
are never fetched (a document that references one is rejected with 400
listing the URLs), and no JavaScript runs.
Try it free
Try it free — 100 renders a month, no card — or paste HTML into the browser-based free HTML→PDF tool, no signup at all.
FAQ
- Can I convert HTML to PDF with curl without an API key?
- Yes. POST /v1/render works anonymously at 10 requests per minute per IP, so a single curl call needs no signup. Sending an X-API-Key header raises that limit and draws on your monthly credits instead.
- What is the maximum HTML size a curl request can send?
- 2 MiB of UTF-8 HTML over REST. Larger payloads are rejected with 413 html_too_large. Because images and fonts must be inlined as data: URIs, that budget is usually spent on assets rather than markup.
- How do I save the PDF to a file with curl?
- The response body is the raw PDF, so redirect it: add --output invoice.pdf to the curl call. The optional filename field in the JSON body only sets the Content-Disposition name.