English

HTML to PDF Converter — Paste Code, Save PDF

Turn HTML code into a PDF with the paper size and margins you choose

Runs in your browser · nothing is uploaded

Paste a fragment (<div>…) or a whole document (<html>…). For a whole document, only the <body> content and <style> blocks are used.

Styles to add. @media print rules apply too.

Paper
Orientation
Margins

For security and privacy, images, fonts and CSS that are not data: or blob: addresses are never requested, and scripts never run. Converting a web page by its URL is not offered.

Preview (printable width)

Enter HTML to see a preview.

In the print dialog, choose "Save as PDF" as the destination. The PDF keeps real, searchable text; the browser decides the page breaks.

Cuts the preview into page-sized pictures. Downloads directly without a dialog, but text cannot be searched or copied, and a page may break in the middle of a line.

What it does

Quotes, receipts and email templates are often HTML. Paste the HTML and CSS here, see a preview at the printable width of the paper you chose, and save it as a PDF in one of two ways: through the print dialog for a text PDF, or as an image PDF downloaded directly. The code stays on this page; nothing is sent to a server.

How to use

  1. Paste the HTML. For a whole document (<html>…), only the <body> content and <style> blocks are used. Add CSS in the second box if you like.
  2. Pick the paper (A4, Letter, A3), orientation and margins, and whether backgrounds print.
  3. Check the preview and press Save as PDF from the print dialog, then choose “Save as PDF” as the destination.
  4. Or press Download an image PDF for a PDF made of page pictures.

How it works

  • Cleaning: the code is parsed with DOMParser (an inert document) and the browser’s CSS parser; every address that is not data: or blob: (images, @import, url(), srcset), script, iframe, object and link elements, and on* attributes are removed. Removed addresses are listed.
  • Preview frame: a sandboxed iframe without script permission and with a Content-Security-Policy that blocks requests and scripts.
  • Paper: A4 210×297 mm and A3 297×420 mm (ISO 216), Letter 8.5×11 in; print mode sets size and margins with CSS @page.
  • Image PDF: the content, laid out at the printable width (680 px for A4 with 15 mm margins), is captured page by page at 2× and stored as JPEG, up to 50 pages, using html-to-image (MIT) and pdf-lib (MIT).

Examples

Goal Steps
A searchable quote PDF Insert example → A4, normal margins → print dialog → Save as PDF
A file straight away on a phone Download an image PDF
A wide table Landscape, narrow margins

To save HTML as a PNG image, use HTML to Image; for Markdown, use Markdown to PDF.

FAQ

Can I convert a web page by its URL?

No. Only pasted HTML is converted. Fetching another site on your behalf would send it requests from your device, possibly with your sign-in. To save a web page, open it and use the browser's Print → Save as PDF.

What is the difference between the two buttons?

Save as PDF from the print dialog uses the browser's own printing, so text stays searchable and page breaks fall between lines. Download an image PDF skips the dialog but stores each page as a picture, so text cannot be selected and a page may break mid-line.

Why are my images or web fonts missing?

For security and privacy, images, fonts and stylesheets that are not data: or blob: addresses are never requested. Embed images as Base64 data: URLs; text uses the fonts installed on the device.

What happens to scripts?

script elements and event attributes such as onclick are removed, and the preview frame has a policy that blocks scripts, so nothing in the pasted code runs.

Can I control page breaks?

In print mode, CSS such as `break-before: page` is honoured, and `@media print` rules in the CSS box apply only when printing.

Missing a tool?