Puppeteer alternative

Puppeteer for PDFs, without the Chrome

If you use Puppeteer to turn HTML into PDFs, Forme renders the same HTML and print CSS in-process — no headless browser to install, launch, sandbox, or keep warm. It replaces the PDF half of Puppeteer, not the browser-automation half.

Your Puppeteer call, replaced
import { renderHtml } from '@formepdf/html';

// Same HTML. No browser, no subprocess.
const { pdf, warnings } = await renderHtml(html);

~20ms typical render for a 6-page report, vs ~1-5s with Chrome boot.

0 browser dependencies — nothing to apt-get, no sandbox flags.

Honest benchmarks, including where a warm Puppeteer wins on very large tables.

Side by side

The same job, before and after

Rendering HTML

Before · Puppeteer
import puppeteer from 'puppeteer';

// Requires Chrome installed, Docker config,
// 200MB binary, sandbox flags...
const browser = await puppeteer.launch({
  args: ['--no-sandbox', '--disable-setuid-sandbox'],
  executablePath: process.env.CHROME_PATH });
const page = await browser.newPage();
await page.setContent(html, { waitUntil: 'networkidle0' });
const pdf = await page.pdf({ format: 'A4' });
await browser.close();
After · Forme
import { renderHtml } from '@formepdf/html';

// Same HTML. No browser, no subprocess.
const { pdf, warnings } = await renderHtml(html);

Repeating headers and page numbers

Before · Puppeteer
/* Guess and check. Sometimes works. */
@media print {
  .header { position: fixed; top: 0; }
  /* Hope the browser repeats it... */
}
.table-row { page-break-inside: avoid; }
After · Forme
@page {
  margin: 72pt 54pt;
  @top-center { content: "ACME WIDGET CO."; }
  @bottom-right { content: counter(page); }
}
@page :first { @top-center { content: none; } }
h2 { break-before: page; }

Deployment

Before · Puppeteer
FROM node:20

# Install Chrome dependencies (500MB+)
RUN apt-get update && apt-get install -y \
  chromium fonts-liberation \
  --no-install-recommends

ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
After · Forme
npm install @formepdf/html

# WASM runs anywhere: Node, Bun, Deno,
# Cloudflare Workers, Vercel Edge, Lambda,
# and the browser. Zero native dependencies.

Comparison

Forme vs Puppeteer for PDF generation

FeatureFormePuppeteer
Runs without a browserYes (WASM, in-process)No (headless Chrome)
Print CSS: @page, margin boxes, countersYes, incl. @page :firstPartial (no margin boxes)
Page breaksPage-native layout (widows/orphans)CSS page-break (fragile)
Table headersAutomatic on every pageInconsistent <thead>
Render speed~20ms (6-page report)~1-5s (Chrome boot)
MemoryNo browser process (WASM)~50-200MB
PDF/A archival conformancePDF/A-2, A-3, A-4/A-4f — veraPDF-verified, composes with PDF/UA-1 and UA-2No (Chrome print output isn't PDF/A)
Redaction, merging, certificationBuilt in: redactText(), mergePdfs(), certifyPdf()No
Execute page JavaScript, screenshots, scrapingNo — not a browserYes

Measured per document and per runtime on a fixed corpus. See the benchmarks →

Be honest about scope

When Puppeteer is still the right tool

Your PDF depends on page JavaScript

If the document is assembled by scripts running in the page — charts drawn on a canvas at runtime, client-side data fetching — you need a browser. Forme renders HTML and CSS, not a running page.

You need screenshots or scraping

Puppeteer automates a whole browser. Forme replaces the PDF output, not navigation, clicking, or capture.

You rely on full browser CSS

Forme implements a documented subset and warns by name on anything outside it. Check the subset table against your templates first.

Checked against 15 real templates from GitHub: 14 render correctly, 1 degrades with its cause named, 0 broken. How it was measured →

Migration

Moving off Puppeteer in four steps

  1. 01

    Install the HTML engine

    One package, no system libraries.

    npm install @formepdf/html
  2. 02

    Swap the render call

    Replace launch, newPage, setContent, and pdf with one call. Keep your HTML as it is.

    import { renderHtml } from '@formepdf/html';
    
    // Same HTML. No browser, no subprocess.
    const { pdf, warnings } = await renderHtml(html);
  3. 03

    Read the warnings

    renderHtml returns a warnings array naming any CSS outside the supported subset, and any render defect where the engine had to compromise. Fix those, and nothing is silently dropped.

  4. 04

    Move print layout into @page

    Replace fixed-position headers and footers with @top-center and @bottom-right margin boxes and counter(page).

Puppeteer migration questions

Is Forme a drop-in Puppeteer alternative?
For document rendering, largely yes — you pass HTML and get bytes back. What differs is scope: Puppeteer automates a whole browser, so if you depend on running JavaScript in the page, screenshotting live sites, or scraping, Forme does not replace that. It replaces the PDF half, without the Chrome half.
Will my existing HTML render the same?
Most templates do. Forme was graded against Chrome print on 15 production templates from GitHub: 14 rendered correctly and 1 degraded legibly with its cause named. Anything outside the supported CSS subset is reported by name in the warnings.
Is Forme faster than Puppeteer?
For typical documents, yes: ~20ms for a 6-page report versus ~1-5s including Chrome boot. A warm Puppeteer can win on very large tables; the published benchmarks show both.
Can I run it on serverless or the edge?
Yes. Forme is WASM, verified in real workerd as well as Node, so it runs on Cloudflare Workers, Vercel Edge, and AWS Lambda without a Chromium layer.