HTML to PDF

Paste HTML or open an .html file, check the rendered page next to the source, and save it as a PDF with your own CSS and print rules.

Source
Preview

In the print dialog, choose “Save as PDF” as the destination.

How to use

  1. Paste your HTML into the editor, or press Open file to load an .html or .htm file (up to 5 MB). You can also drop the file onto the editor.
  2. Check the rendered page next to the source. On a narrow screen, switch between Edit and Preview.
  3. Press Download PDF. In the print dialog, choose Save as PDF as the destination and save.
  4. Press Clear to empty the editor and start a new document.

About this tool

How the conversion works

There is no converter on a server. Your HTML is rendered in a sandboxed frame by your own browser, and Download PDF opens the browser's print dialog for that frame only, without this page's menus or ads. Choosing Save as PDF writes the file with the same print engine your browser uses for any page, so text stays selectable and links stay clickable. The document's title element, or its first h1 if there is no title, becomes the suggested file name.

CSS print tips

  • @page { size: A4; margin: 18mm; } sets the paper size and margins. Use size: letter for US Letter, or add landscape. If a browser ignores size, pick the paper in the print dialog.
  • break-inside: avoid on table rows, figures or cards keeps each one on a single page. break-before: page starts a new page before an element.
  • Browsers drop background colours when printing to save ink. Add print-color-adjust: exact (plus -webkit-print-color-adjust: exact for browsers that still need the prefix) to coloured table headers or labels, or tick the background graphics option in the print dialog.
  • Put screen-only rules inside @media screen and print-only rules inside @media print.

What does not carry over

Scripts in your HTML do not run, because the preview is sandboxed. Anything built by JavaScript, such as charts or content loaded after the page opens, will be missing; paste the finished HTML instead. Web fonts from another site may be blocked by that site's CORS rules and fall back to a system font. Images load from full https:// addresses; a relative path such as img/logo.png has no folder to point to here.

Privacy

Nothing is uploaded. The HTML stays in your browser, and the draft is kept there so it is still in the editor when you come back.

Common mistakes

  • Leaving the print dialog's headers and footers switched on, which adds the date and a page address to every page.
  • Setting a fixed width such as width: 1200px on the body, which gets scaled down or cut off on paper. Use percentages or mm.

Frequently asked questions

Is my HTML uploaded to a server?

No. The HTML is rendered and printed by your own browser, and the draft is kept only in your browser.

Why is JavaScript content missing from the PDF?

Scripts do not run in the sandboxed preview, so anything a script would build, such as charts, does not appear. Paste the finished HTML that the script produced instead.

How do I set the page size and margins?

Add an @page rule to your CSS, for example @page { size: A4; margin: 18mm; }. If your browser ignores the size, choose the paper size in the print dialog.

Why are background colours missing in the PDF?

Browsers leave out backgrounds when printing. Add print-color-adjust: exact to the elements that need them, or turn on background graphics in the print dialog.

How is the PDF file named?

The browser suggests the document's title, or its first h1 heading if there is no title. You can change the name in the save dialog.