HTML to PDF in Node.js, without Puppeteer

The usual Node.js answer for HTML to PDF is Puppeteer — but it pulls 200 to 400 MB of Chromium into your dependency tree and breaks in serverless environments unless you wire up a Chromium layer. pdfkitt moves the browser to the server side, so your app just makes one HTTP call.

One fetch call

No SDK, no Chromium download. Send HTML, get a PDF buffer back, write it to disk or stream it to your user.

import fs from "node:fs/promises";

const res = await fetch("https://api.pdfkitt.dev/v1/convert", {
  method: "POST",
  headers: {
    "Authorization": "Bearer " + process.env.PDFKITT_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    html: "<h1>Invoice</h1>",
    options: { page_size: "A4" },
  }),
});

const pdf = Buffer.from(await res.arrayBuffer());
await fs.writeFile("invoice.pdf", pdf);

When local Puppeteer still makes sense

If you need full browser automation — interactive sessions, screenshots in many formats, or an on-prem environment where outbound API calls are not allowed — running Puppeteer or Playwright yourself is the right call. For plain HTML to PDF in a normal or serverless backend, an API removes the Chromium dependency and the cold-start pain. See how the trade-off plays out on the pdfkitt vs Puppeteer page, or jump straight to the API docs.

Try pdfkitt free — 1,000 PDFs/month, no credit card

Get an API key and send your first PDF in minutes.