Best HTML to PDF API in 2026 — Developer Guide
Generating PDFs from HTML is one of those tasks that sounds simple but quickly becomes painful. Between CSS rendering inconsistencies, page break handling, header/footer logic, and scaling headless browsers, most developers end up spending days on what should be a 10-minute integration.
An HTML to PDF API takes your HTML (or a URL) and returns a well-rendered PDF. No infrastructure to manage, no Puppeteer memory leaks to debug. Here are the best options in 2026.
Common Use Cases for HTML to PDF Conversion
Before diving into the comparison, here's why developers reach for a PDF generation API:
- Invoices and receipts — generate branded PDFs from order data
- Reports and dashboards — export analytics as shareable PDFs
- Contracts and legal documents — render HTML templates as downloadable PDFs
- E-commerce — packing slips, shipping labels, product catalogs
- Certificates — course completion, event attendance, awards
- Resume/CV builders — convert styled HTML to downloadable PDFs
Quick Comparison Table
| API | Free Tier | Paid From | Rendering Engine | HTML Input | URL Input | Headers/Footers | Avg Response |
|---|---|---|---|---|---|---|---|
| HookRay PDF | 100/mo | $9/mo | Chromium | Yes | Yes | Yes | ~2s |
| PDFShift | 50/mo | $9/mo | Chromium | Yes | Yes | Yes | ~3s |
| DocRaptor | 5 test docs | $15/mo | Prince XML | Yes | Yes | Yes (advanced) | ~2s |
| html2pdf.app | 300/mo | $14.90/mo | Chromium | Yes | Yes | Yes | ~2.5s |
| Puppeteer (self-hosted) | Free (OSS) | Infra costs | Chromium | Yes | Yes | Yes | Varies |
1. HookRay PDF — Best for Indie Developers Who Want Zero Infrastructure
Best for: Developers who want a simple API for generating PDFs from HTML or URLs without managing any infrastructure.
HookRay PDF is part of the HookRay developer tools suite. The API accepts raw HTML or a URL and returns a PDF. There's also a browser-based tool where you can paste HTML and generate a PDF instantly — useful for testing templates before integrating the API.
Key Features
- HTML and URL input — send raw HTML or point to a live URL
- Custom page size — A4, Letter, Legal, or custom dimensions
- Headers and footers — add page numbers, dates, custom HTML
- Margin control — set top, bottom, left, right margins
- Landscape mode — switch orientation for wide content
- Browser tool — test your HTML-to-PDF conversion without writing code
Pricing
| Plan | PDFs/mo | Price |
|---|---|---|
| Free | 100 | $0 |
| Pro | 5,000 | $9/mo |
| Business | 25,000 | $29/mo |
Code Example
curl -X POST "https://hookray.com/apis/html-to-pdf" \
-H "Content-Type: application/json" \
-d '{
"html": "<h1>Invoice #1234</h1><p>Total: $99.00</p>",
"format": "A4",
"margin": { "top": "20mm", "bottom": "20mm" }
}' \
--output invoice.pdf
// Node.js
const response = await fetch("https://hookray.com/apis/html-to-pdf", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
html: "<h1>Invoice #1234</h1><p>Total: $99.00</p>",
format: "A4",
}),
});
const pdf = await response.arrayBuffer();
Pros
- Generous free tier (100 PDFs/mo, no credit card)
- Simple API with sensible defaults
- Browser-based testing tool included
- Fast response times (~2s)
- No infrastructure to manage
Cons
- Fewer advanced features than DocRaptor
- No watermarking or password protection yet
- Newer product, smaller community
2. PDFShift — Best Balance of Price and Features
Best for: Developers who need a reliable, well-documented PDF API at a reasonable price.
PDFShift has been around since 2018 and has built a solid reputation. It uses Chromium for rendering, which means your PDFs look exactly like what Chrome would print. The API is well-designed and the documentation is excellent.
Key Features
- Chromium rendering — pixel-perfect CSS support
- Parallel conversions — process multiple PDFs concurrently
- Webhook callbacks — get notified when async conversions complete
- S3 upload — auto-upload generated PDFs to your S3 bucket
- Custom headers — pass authentication headers for protected pages
- Watermarking — add text or image watermarks
Pricing
| Plan | Credits/mo | Price |
|---|---|---|
| Free | 50 | $0 |
| Starter | 500 | $9/mo |
| Boost | 2,500 | $24/mo |
| Growth | 5,000 | $39/mo |
| Enterprise | 25,000 | $124/mo |
Code Example
import requests
response = requests.post(
"https://api.pdfshift.io/v3/convert/pdf",
auth=("api", "your_api_key"),
json={
"source": "<h1>Hello World</h1>",
"landscape": False,
"use_print": True,
},
)
with open("output.pdf", "wb") as f:
f.write(response.content)
Pros
- Mature, battle-tested product (since 2018)
- Excellent documentation with examples in 8+ languages
- S3 integration and webhook callbacks
- Watermarking support
- Reasonable pricing
Cons
- 50 free credits/mo (less generous than alternatives)
- Response times can be inconsistent (2-5s)
- Rate limiting on lower tiers
- No browser-based testing tool
3. DocRaptor — Best for Complex Document Layouts
Best for: Teams generating complex documents with precise page break control, table of contents, and print-quality typography.
DocRaptor uses Prince XML as its rendering engine instead of Chromium. This gives it superior control over pagination, table of contents generation, and print-specific CSS features. If you're generating contracts, books, or complex reports, DocRaptor handles edge cases that Chromium-based APIs struggle with.
Key Features
- Prince XML engine — the gold standard for print CSS
- Advanced pagination — precise page break control, widows/orphans
- Table of contents — auto-generated from heading structure
- Named pages — different layouts for different page types
- Footnotes — proper footnote rendering
- JavaScript execution — run JS before PDF generation
Pricing
| Plan | Docs/mo | Price |
|---|---|---|
| Test | 5 (watermarked) | $0 |
| Basic | 125 | $15/mo |
| Professional | 325 | $29/mo |
| Premium | 1,250 | $75/mo |
| Max | 5,000 | $209/mo |
Code Example
# Ruby
require "docraptor"
client = DocRaptor::DocApi.new
client.api_key = "YOUR_API_KEY"
response = client.create_doc(
test: false,
document_type: "pdf",
document_content: "<h1>Contract Agreement</h1>...",
prince_options: {
media: "print",
baseurl: "https://example.com",
}
)
File.write("contract.pdf", response)
Pros
- Best rendering engine for complex documents
- Superior page break and pagination control
- Auto-generated table of contents
- Footnote and cross-reference support
- Excellent for print-quality output
Cons
- More expensive per document than alternatives
- Prince XML has a learning curve (different CSS model)
- Test documents are watermarked
- Only 5 free test docs (not a real free tier)
- Overkill for simple invoices or receipts
4. html2pdf.app — Best for High-Volume Simple Conversions
Best for: Developers who need a large number of basic HTML-to-PDF conversions at a competitive price.
html2pdf.app is a straightforward API focused on doing one thing well: converting HTML to PDF using Chromium. It offers the most generous free tier in this comparison (300 conversions/month) and scales affordably.
Key Features
- Chromium-based rendering — modern CSS and JavaScript support
- Generous free tier — 300 conversions per month
- Custom page sizes — predefined and custom dimensions
- Header/footer templates — HTML-based headers and footers
- CSS @page support — use print stylesheets
- Batch conversion — convert multiple documents in one request
Pricing
| Plan | Conversions/mo | Price |
|---|---|---|
| Free | 300 | $0 |
| Startup | 2,000 | $14.90/mo |
| Business | 10,000 | $49.90/mo |
| Enterprise | 50,000 | $149.90/mo |
Code Example
const response = await fetch("https://api.html2pdf.app/v1/generate", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer YOUR_API_KEY",
},
body: JSON.stringify({
html: "<h1>Report</h1><p>Generated on 2026-04-02</p>",
format: "A4",
marginTop: 20,
marginBottom: 20,
}),
});
Pros
- Most generous free tier (300/mo)
- Competitive pricing at scale
- Simple, well-documented API
- Batch conversion support
- Good Chromium rendering quality
Cons
- Limited advanced features
- No S3 integration or webhook callbacks
- Documentation is less detailed than PDFShift
- No watermarking or password protection
5. Puppeteer (Self-Hosted) — Best for Full Control
Best for: Teams that need complete control over the PDF generation pipeline and have the infrastructure to support it.
Puppeteer's page.pdf() method is what most hosted APIs are built on top of. If you're already running Node.js services and have DevOps capacity, self-hosting gives you unlimited conversions at infrastructure cost only.
Key Features
- Full Chromium control — every Chrome DevTools Protocol feature
- No per-document costs — pay only for infrastructure
- Custom rendering logic — wait for specific elements, run JS, inject CSS
- Authentication — handle login flows before capture
- Local file access — render private HTML files
Self-Hosting Costs
| Scale | Infrastructure | Monthly Cost |
|---|---|---|
| Light (500/mo) | 1x 2GB VPS | ~$10-20/mo + maintenance |
| Medium (5K/mo) | 2x 4GB instances | ~$40-80/mo + maintenance |
| Heavy (50K/mo) | Kubernetes cluster | ~$150-400/mo + maintenance |
Code Example
const puppeteer = require("puppeteer");
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setContent(`
<html>
<head><style>body { font-family: sans-serif; }</style></head>
<body><h1>Invoice #1234</h1><p>Total: $99.00</p></body>
</html>
`);
await page.pdf({
path: "invoice.pdf",
format: "A4",
margin: { top: "20mm", bottom: "20mm", left: "15mm", right: "15mm" },
printBackground: true,
});
await browser.close();
Pros
- No per-document costs
- Complete control over rendering
- Can handle authenticated pages and local files
- Unlimited customization
Cons
- You manage the infrastructure (updates, scaling, monitoring)
- Puppeteer memory leaks are a real problem at scale
- Font rendering requires manual font installation
- No built-in queuing, retries, or error handling
- Significant DevOps overhead
HTML to PDF API Feature Comparison
| Feature | HookRay | PDFShift | DocRaptor | html2pdf.app | Puppeteer |
|---|---|---|---|---|---|
| Rendering engine | Chromium | Chromium | Prince XML | Chromium | Chromium |
| Free tier | 100/mo | 50/mo | 5 test | 300/mo | Free (OSS) |
| Starting price | $9/mo | $9/mo | $15/mo | $14.90/mo | Infra only |
| HTML input | Yes | Yes | Yes | Yes | Yes |
| URL input | Yes | Yes | Yes | Yes | Yes |
| Headers/footers | Yes | Yes | Advanced | Yes | Yes |
| Watermarking | No | Yes | No | No | DIY |
| S3 upload | No | Yes | No | No | DIY |
| Browser tool | Yes | No | No | No | No |
| Best for | Simplicity | Balance | Complex docs | Volume | Full control |
How to Choose the Right HTML to PDF API
Choose HookRay PDF if:
- You want a simple API with a free tier and no credit card
- You're building invoices, receipts, or basic reports
- You want to test in the browser before writing code
- Infrastructure simplicity matters more than advanced features
Choose PDFShift if:
- You need a mature, reliable API with S3 integration
- Watermarking or webhook callbacks are important
- You want excellent documentation across multiple languages
Choose DocRaptor if:
- You're generating complex documents (contracts, books, reports)
- Precise pagination and table of contents matter
- You need print-quality typography and layout control
Choose html2pdf.app if:
- You need the most generous free tier (300/mo)
- Your use case is straightforward HTML-to-PDF conversion
- Volume pricing is your primary concern
Choose self-hosted Puppeteer if:
- You have DevOps capacity and existing infrastructure
- You need to render private or authenticated content
- Your volume justifies the infrastructure investment
The Bottom Line
For most developers, a managed HTML to PDF API is the right call. The Puppeteer memory leak debugging alone will cost you more in engineering time than any API subscription.
If you're building a side project or early-stage product, HookRay PDF gives you 100 free conversions per month with zero setup — enough to validate your idea and serve your first users before committing to a paid plan.
Generate your first PDF in seconds — no signup required. Try the HookRay PDF tool in your browser, or integrate directly via the HTML to PDF API.
Ready to test your webhooks?
Get a free webhook URL in 5 seconds. No signup required.
Start Testing — Free