Node.js HTML to PDF API
Convert any URL into a pixel-perfect PDF document in three lines of Node.js — no Puppeteer, no Chromium, no servers to maintain.
Convert a URL to PDF in Node.js
The official SDK, @microlink/mql, is a tiny Promise-based client. Install it, point it at a URL, and you get back a hosted PDF URL — ready to embed, download, or store.
Step 01 · Install the SDK
A single dependency with zero native binaries. It runs anywhere Node runs.
npm install @microlink/mqlStep 02 · Convert any URL
Pass the page you want and set pdf: true. With async/await you get the result in one call — both CommonJS (require) and ESM (import) are supported.
convert.js
import mql from '@microlink/mql'
// CommonJS: const mql = require('@microlink/mql')
const { status, data } = await mql('https://example.com', {
pdf: true,
meta: false // skip metadata extraction for a faster response
})
if (status === 'success') {
console.log(data.pdf.url)
}Step 03 · Customize the document
Paper format, margins, orientation, scale, and print CSS — every document option is just a field.
options.js
const { data } = await mql('https://example.com', {
pdf: {
format: 'A4', // A0-A6 | Letter | Legal | Tabloid
margin: '0.35cm', // cm, mm, in or px
landscape: false, // portrait (default) | landscape
scale: 1 // zoom the rendering, 0.1 to 2
},
mediaType: 'print', // print CSS stylesheets | screen (default)
waitForTimeout: 1000 // wait before generating
})Step 04 · Save it to disk
The response is a hosted PDF URL on a global CDN. Use the built-in fetch to download it, or just hand the URL to the browser.
save.js
import { writeFile } from 'node:fs/promises'
import mql from '@microlink/mql'
const { data } = await mql('https://example.com', { pdf: true })
const response = await fetch(data.pdf.url)
const buffer = Buffer.from(await response.arrayBuffer())
await writeFile('document.pdf', buffer)Drop it into your framework
A route handler, a controller, or a plain HTTP server — the same three-line call becomes your own PDF endpoint, perfect for invoices, reports, and receipts on any runtime.
- Express
- Next.js
- Fastify
- NestJS
- Node.js
import mql from '@microlink/mql'
// GET /api/pdf?url=https://example.com
export async function GET (request) {
const { searchParams } = new URL(request.url)
const url = searchParams.get('url')
const { data } = await mql(url, {
pdf: true,
meta: false
})
// redirect to the hosted document, or return data.pdf.url as JSON
return Response.redirect(data.pdf.url)
}Skip the Puppeteer maintenance
Running page.pdf() yourself means shipping a 300 MB browser, tuning memory, and fighting cold starts. The API gives you the same rendering engine without any of the infrastructure.
Self-hosted Puppeteer
- Bundle & maintain Chromium (~300 MB) plus system libraries and fonts
- Exceeds the AWS Lambda 50 MB limit — needs chrome-aws-lambda hacks
- Each browser eats hundreds of MB of RAM; OOM crashes under load
- Launching Chromium adds seconds of cold-start latency per document
- You build the browser pool, queueing, retries and autoscaling
- Write your own cookie-banner & ad dismissal scripts
Microlink for Node.js
- npm install @microlink/mql — pure JavaScript, zero binaries
- Runs anywhere: serverless, edge, containers, your laptop
- Autoscaled managed browser fleet with a 99.9% uptime SLA
- Sub-second cached responses from 330+ edge locations
- A0-A6, Letter, Legal & Tabloid — typed options with autocomplete
- Print or screen CSS, custom styles & DOM interaction included
Built for the way you write Node.
A REST API designed to feel native in JavaScript — typed, Promise-based, and at home in any runtime, from a long-running server to a Cloudflare Worker. Read the PDF guide to go deeper.
TypeScript Ready
Ships type definitions out of the box, so every PDF option autocompletes and type-checks in your editor.
ESM & CommonJS
Use `import mql from "@microlink/mql"` or `require("@microlink/mql")` — it works in any Node project without config.
Serverless & Edge Friendly
No Chromium binary to bundle. Deploy to Vercel, AWS Lambda, or Cloudflare Workers with the lightweight build.
Promise-Based API
A single async call returns the hosted document URL. No callbacks, no streams to manage, no browser lifecycle to babysit.
Zero Infrastructure
No browser pool to babysit inside your process. The managed Chrome fleet runs outside your event loop, so your app stays a thin HTTP client.
Custom Paper & Layout
Pass a `pdf` object with format, margin, landscape, scale, and pageRanges — every field autocompletes from the bundled type definitions.
Screen & Print Media
Add `mediaType: "print"` to the same options object to render print stylesheets instead of the on-screen layout.
Global Edge Caching
Repeat conversions are served sub-second from 330+ edge locations, with configurable TTL to keep documents fresh.
Generous Free Tier
Start with 25 requests per day — no account, no credit card. Pass `apiKey` to `mql()` when you outgrow it.
TypeScript Ready
Ships type definitions out of the box, so every PDF option autocompletes and type-checks in your editor.ESM & CommonJS
Use `import mql from "@microlink/mql"` or `require("@microlink/mql")` — it works in any Node project without config.Serverless & Edge Friendly
No Chromium binary to bundle. Deploy to Vercel, AWS Lambda, or Cloudflare Workers with the lightweight build.
Promise-Based API
A single async call returns the hosted document URL. No callbacks, no streams to manage, no browser lifecycle to babysit.Zero Infrastructure
No browser pool to babysit inside your process. The managed Chrome fleet runs outside your event loop, so your app stays a thin HTTP client.Custom Paper & Layout
Pass a `pdf` object with format, margin, landscape, scale, and pageRanges — every field autocompletes from the bundled type definitions.
Screen & Print Media
Add `mediaType: "print"` to the same options object to render print stylesheets instead of the on-screen layout.Global Edge Caching
Repeat conversions are served sub-second from 330+ edge locations, with configurable TTL to keep documents fresh.Generous Free Tier
Start with 25 requests per day — no account, no credit card. Pass `apiKey` to `mql()` when you outgrow it.
Try it live in the playground
Paste a URL and see the exact API request before you write a line of Node.
Node.js PDF FAQ
What Node developers ask before integrating. For formats, limits, and SLA, see the PDF API overview.
Do I need Puppeteer or Chromium installed?
No.
@microlink/mql is a thin HTTP client with zero native dependencies — there is no Chromium binary to download and nothing to compile. The Headless Chrome fleet runs on Microlink's side.That is what makes it deploy cleanly to serverless and edge environments where bundling Puppeteer is painful.
How do I save or stream the PDF in Node.js?
The response gives you
data.pdf.url, a hosted document on the CDN. Fetch it and write the buffer to disk, pipe it into an upload, or redirect the browser straight to it — the bytes never have to pass through your server.If you would rather get the file back inline instead of a URL, the delivery & embedding guide covers the
embed parameter.Does it work with TypeScript?
Yes. The package ships its own type definitions, so the
mql() client and every PDF option are typed and autocomplete in your editor — no @types package required.Does it run on Next.js, serverless, or the edge?
Yes. Because there is no browser binary to bundle, it works inside Next.js Route Handlers, AWS Lambda, and Vercel functions out of the box. For the Edge runtime, import the lightweight build:
@microlink/mql/lightweight.See the installation guide for runtime details.
How do I use my API key with mql?
Pass
apiKey in the options object. The SDK sends it as the x-api-key header and switches the request to pro.microlink.io for you, so there is no endpoint to change by hand.Free usage needs no key at all. See pricing for the tiers, or the authentication docs for the details.
Can I convert several URLs in parallel?
Yes — each call is an independent HTTP request, so
Promise.all over a list of URLs works as you would expect. There is no browser instance in your process to contend over.Throughput is bounded by your plan rather than your hardware; check the rate limit docs before fanning out widely.
Start converting in Node.js
Get 25 requests/day with zero commitment — no account and no credit card. Install the SDK and ship your first PDF in minutes.
No login needed
25 reqs/day free
No credit card