MostlyPDF

HTML to PDF

Paste your HTML (or HTML + inline CSS) and render it to a clean, paginated A4 PDF — also available as an API.

Open HTML to PDF

How to use HTML to PDF

  1. Upload your fileDrop your PDF onto the HTML to PDF tool, or browse to select.
  2. Set your optionsChoose how you want HTML to PDF to run — the options that matter, nothing more.
  3. DownloadRun the tool and download your finished file instantly.
Accepts
Pasted HTML, with inline or embedded CSS
Gives you
A paginated PDF (A4, US Letter or US Legal)
Where it runs
On our servers, over an encrypted connection; deleted within 24 hours
Price
Free — no sign-up, no watermark

HTML to PDF in Python and Node.js

The same engine is one POST away. Send the HTML with your API key; the response carries a link to the finished PDF. Create a key in the app under API keys — the full reference is at /docs.

Python

import os, requests

r = requests.post(
    "https://mostly-pdf.web.app/v1/process",
    headers={"Authorization": f"Bearer {os.environ['MOSTLYPDF_API_KEY']}"},
    json={"tool": "html-to-pdf",
          "options": {"html": "<h1>Invoice #42</h1><p>Thank you!</p>", "paper": "A4"}},
    timeout=60,
)
r.raise_for_status()
pdf = requests.get(r.json()["pdfUrl"], timeout=60).content
with open("invoice.pdf", "wb") as f:
    f.write(pdf)

Node.js

// Node 18+ (ES module) — fetch is built in
import { writeFile } from 'node:fs/promises';

const res = await fetch('https://mostly-pdf.web.app/v1/process', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.MOSTLYPDF_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    tool: 'html-to-pdf',
    options: { html: '<h1>Invoice #42</h1><p>Thank you!</p>', paper: 'A4' },
  }),
});
if (!res.ok) throw new Error(await res.text());
const { pdfUrl } = await res.json();
await writeFile('invoice.pdf', Buffer.from(await (await fetch(pdfUrl)).arrayBuffer()));

Common questions

Is HTML to PDF free?

Yes — HTML to PDF is free with no sign-up, no watermark and no daily limit on this tool. Heavier operations (OCR, conversion) have a generous daily quota on the free plan and are unlimited on Pro.

How do I convert html to pdf api?

Open HTML to PDF, drop your file, set the options, and download the result in a few seconds — processed securely, no queue and no ads.

Are my files safe?

HTML to PDF needs our conversion servers, so the file is sent over an encrypted connection, used only for your task and deleted within 24 hours. The page tools (merge, split, rotate, organize, page numbers, watermark, crop, form filling, image to PDF) run entirely in your browser instead and never upload anything.

Is the CSS actually applied?

Yes. The HTML is rendered by a real headless browser, so your CSS, web fonts and layout are applied exactly as they would be on screen, then paginated with print margins.

Can I call this from my own code?

Yes — the same conversion is available on the MostlyPDF API: send the HTML with your API key and get back a hosted PDF URL. It runs on MostlyRender, the Chromium print-to-PDF engine behind these tools.

All tools

Compare: MostlyPDF vs iLovePDF · MostlyPDF vs Smallpdf · MostlyPDF vs PDF24 · MostlyPDF vs Sejda · MostlyPDF vs Stirling PDF

A Mostly Tiny product · All tools