OpenToolbox

Free HTML to PDF

HTML to PDF turns HTML and CSS into a paginated PDF with real, selectable text and working links. Paste code, open an .html file or start from the invoice, letter or report template, then set page size, margins, and headers or footers with page numbers. Scripts are removed, so content built by JavaScript does not appear.

Input:
HTML and CSS, or an .html file
Pagination:
CSS paged media via Paged.js
Templates:
Invoice, letter, report
Price:
Free
Runs:
Locally, in your browser
Uploads:
None: files never leave your device
Account:
Not needed

Quick answers

Is my HTML uploaded to convert it?

No. The pages are laid out in your browser by Paged.js and the PDF is written by your browser's print engine. Nothing is sent anywhere.

Why does a print dialog open?

Browsers can't save a file from a web page without asking you, and their print engine makes the best PDFs: real selectable text, crisp fonts and working links. Choose “Save as PDF” (or “Microsoft Print to PDF”) as the printer and click Save.

Loading tool…

Processed on your device: your files are never uploaded. How it works

How to use the HTML to PDF

  1. Paste or type your HTML (with CSS in <style> tags), open an .html file, or start from the invoice, letter or report template.
  2. Set the page size, orientation, margins, header and footer (with page numbers) and check the paginated preview.
  3. Click Save as PDF and choose “Save as PDF” as the destination in your browser's print dialog.

Credits & open source

Built on open-source libraries. Thank you to the people who make these projects.

  • Paged.jsPaginates HTML for print with CSS paged media (page numbers, margins). © Adam Hyde, Fred Chasen and the Coko Foundation · MIT
  • DOMPurifySanitizes HTML to prevent script injection. © Mario Heiderich, Cure53 and contributors · MPL-2.0 OR Apache-2.0
  • CodeMirror 6Code editor with syntax highlighting. © Marijn Haverbeke and others · MIT
  • @uiw/react-codemirrorReact wrapper for CodeMirror 6. © Kenny Wong (uiwjs) · MIT

Web platform APIs used: File API, localStorage, Intl, Web Crypto.

Full license texts: third-party notices · all credits

Frequently asked questions

How do I add page numbers?

Type {page} and {pages} in the header or footer box, for example “Page {page} of {pages}”. {title} inserts the document title and {date} today's date.

Can I force a page break?

Yes. Add the CSS break-before: page (or break-after: page) to an element. Use break-inside: avoid to keep a block, like a table row, on one page.

Does JavaScript in my HTML run?

No. Scripts and event handlers are removed for safety, so content created by JavaScript won't appear. Plain HTML and CSS work.

My background colors are missing in the PDF.

Keep “Print background colors and images” on, and if your browser still drops them, tick “Background graphics” in its print dialog.

More pdf tools