HTML to PDF in Node.js
Render HTML to PDF from Node.js with the built-in fetch — no Puppeteer, no Chromium download. One POST request, copy-paste example inside.
Skip Puppeteer and the Chromium download entirely — Node's built-in
fetch (Node 18+) is enough:
import { writeFile } from "node:fs/promises";
const res = await fetch("https://api.pdfrender.dev/v1/render", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": process.env.PDFRENDER_KEY, // optional — anonymous works too
},
body: JSON.stringify({
html: "<h1>Hello</h1><p>Rendered from Node.js.</p>",
filename: "hello.pdf",
}),
});
if (!res.ok) throw new Error(`render failed: ${res.status} ${await res.text()}`);
await writeFile("hello.pdf", Buffer.from(await res.arrayBuffer()));
The response body is the PDF itself (application/pdf), so there is nothing
to decode — write the bytes and you are done.
What renders
The engine is WeasyPrint: HTML + CSS, including print-specific CSS
(@page, margin boxes, page counters). JavaScript in your document does NOT
execute — if your page needs client-side JS to reach its final state, render
that state into the HTML server-side first. External http(s) images, fonts
and stylesheets are not fetched; inline them as data: URIs
(how).
Try it free
Try it free — 100 renders a month, no card — or try the browser-based tool with zero setup.