·11 min read·comparison, pdf-api, developer-tools, api

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

APIFree TierPaid FromRendering EngineHTML InputURL InputHeaders/FootersAvg Response
HookRay PDF100/mo$9/moChromiumYesYesYes~2s
PDFShift50/mo$9/moChromiumYesYesYes~3s
DocRaptor5 test docs$15/moPrince XMLYesYesYes (advanced)~2s
html2pdf.app300/mo$14.90/moChromiumYesYesYes~2.5s
Puppeteer (self-hosted)Free (OSS)Infra costsChromiumYesYesYesVaries

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

PlanPDFs/moPrice
Free100$0
Pro5,000$9/mo
Business25,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

PlanCredits/moPrice
Free50$0
Starter500$9/mo
Boost2,500$24/mo
Growth5,000$39/mo
Enterprise25,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

PlanDocs/moPrice
Test5 (watermarked)$0
Basic125$15/mo
Professional325$29/mo
Premium1,250$75/mo
Max5,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

PlanConversions/moPrice
Free300$0
Startup2,000$14.90/mo
Business10,000$49.90/mo
Enterprise50,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

ScaleInfrastructureMonthly 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

FeatureHookRayPDFShiftDocRaptorhtml2pdf.appPuppeteer
Rendering engineChromiumChromiumPrince XMLChromiumChromium
Free tier100/mo50/mo5 test300/moFree (OSS)
Starting price$9/mo$9/mo$15/mo$14.90/moInfra only
HTML inputYesYesYesYesYes
URL inputYesYesYesYesYes
Headers/footersYesYesAdvancedYesYes
WatermarkingNoYesNoNoDIY
S3 uploadNoYesNoNoDIY
Browser toolYesNoNoNoNo
Best forSimplicityBalanceComplex docsVolumeFull 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