PDF4.dev: PDF generation for developers

PDF4.dev is a PDF generation API that lets developers create pixel-perfect PDFs from HTML templates. Design templates visually or in code using a Monaco-based editor with live preview, define dynamic fields with Handlebars {{variables}}, and generate PDFs via a simple REST API call from any language: TypeScript, Python, Go, Rust, PHP, or cURL. The rendering pipeline uses headless Chromium (Playwright) for accurate CSS support including flexbox, grid, and web fonts. PDF4.dev also provides a built-in MCP server so AI agents like Claude, ChatGPT, and Cursor can generate PDFs with natural language. Free browser-based PDF tools (merge, split, compress, convert) process files entirely client-side for privacy. Self-hostable via Docker with SQLite storage, PDF4.dev is a developer-first alternative to PDFMonkey, DocRaptor, and DIY Puppeteer setups.

Key facts

Features

AI-native: built for AI agents

PDF4.dev is the first PDF API with native MCP (Model Context Protocol) support. 14 MCP tools let AI agents like Claude, ChatGPT, Cursor, Windsurf, and VS Code generate PDFs with natural language. The MCP server supports visual preview and full template CRUD.

PDF4.dev vs the alternatives

FeaturePDF4.devDIY PuppeteerPDFMonkey
Setup time~5 minutesHours of config~30 minutes
Template editorCode + visual editorBuild your ownBasic
Live previewYesBuild your ownPartial
Non-technical editingVisual editor: no codeCode onlyBasic editor
API docsOpenAPI 3.1Write your ownBasic
Usage limitsGenerousNone20-5,000/mo
Language supportAny (REST API)Node.js onlyLimited SDKs
Integration time~5 minutesDays to weeks~30 minutes
MaintenanceManagedAll on youManaged
Reusable componentsHeaders, footers, blocksBuild your ownNone
Batch generationCSV/JSON upload, ZIP downloadBuild your ownAPI only
AI agent supportMCP server with annotationsNoneNone

Free PDF tools

24 free browser-based PDF tools. Files never leave your browser.

How it works

  1. Design your template in the visual editor or write HTML with Handlebars variables like {{company_name}} and {{amount}}.
  2. Send a POST request to /api/v1/render with your template ID and data. The API accepts JSON and returns a PDF binary.
  3. Receive a pixel-perfect PDF in ~300ms. The rendering engine uses headless Chromium for full CSS support.

API usage

Generate a PDF with a single POST request. Send your template ID and data as JSON, receive a PDF binary. Works with TypeScript, Python, Go, Rust, PHP, and cURL. Bearer token authentication with OpenAPI 3.1 spec.

Get started

PDF generation
for developers

Design templates visually. Render via API in ~300ms. Any language.

~300msavg generation
~5 minto integrate
Anylanguage
pdf4.dev/dashboard/templates/invoice
PDF4.dev visual editor showing an invoice template with layers panel, canvas, and sample data

One POST. One PDF.

Works with any language that can send an HTTP request.

const res = await fetch('https://pdf4.dev/api/v1/render', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer p4_live_xxxxx',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    template_id: 'invoice',
    data: {
      company: 'Acme Corp',
      amount: '$1,500.00',
      date: '2026-03-06'
    }
  })
})

const pdf = await res.blob() // That's it.
✓ 200 OKapplication/pdf · 142KB · 312ms

Beautiful documents,
every time

Invoice PDFInvoice
Report PDFReport
Quote PDFQuote
Receipt PDFReceipt
Invoice PDF
Report PDF
Quote PDF
Receipt PDF
Invoice

Everything you need.
Nothing you don't.

Monaco code editor

Full HTML editor with syntax highlighting and Handlebars autocompletion. For when your team needs full control.

Visual editor

Edit templates visually, no code required. Perfect for business teams who update designs without waiting on developers.

Live preview

See your PDF render in real-time as you type. Accurate page dimensions and margins.

6 PDF formats

A4, Letter, landscape, square, or fully custom. Configurable margins, fonts, and background.

REST API

Bearer auth, OpenAPI 3.1 spec, interactive docs. Works with any language: TypeScript, Python, Go, Rust, PHP, cURL.

Reusable components

Headers, footers, and blocks: create once, share across templates. Headers and footers repeat on every page automatically.

Batch generate

Upload a CSV or JSON, map columns to variables, and generate hundreds of PDFs in one click. Download as ZIP.

Generation logs

Full history: status, duration, file size. Filterable and cursor-paginated.

Built for AI agents

The first PDF API with native MCP support. Connect your favorite AI tool and generate PDFs with natural language.

AI AgentLive
_

14 MCP tools · Visual preview · Natural language control

PDF4.dev vs the alternatives

PDF4.devDIY PuppeteerPDFMonkey
Setup time~5 minutesHours of config~30 minutes
Template editorCode + visual editorBuild your ownBasic
Live previewYesBuild your ownPartial
Non-technical editingVisual editor: no codeCode onlyBasic editor
API docsOpenAPI 3.1Write your ownBasic
Usage limitsGenerousNone20-5,000/mo
Language supportAny (REST API)Node.js onlyLimited SDKs
Integration time~5 minutesDays to weeks~30 minutes
MaintenanceManagedAll on youManaged
Reusable componentsHeaders, footers, blocksBuild your ownNone
Batch generationCSV/JSON upload, ZIP downloadBuild your ownAPI only
AI agent supportMCP server with annotationsNoneNone

PDF tools that run in your browser

Guides and tutorials

All articles

Ready to generate
your first PDF?

Free to start. No credit card required.