HTML to PDF — Turn HTML Code into a Shareable PDF

Paste your markup or open a saved .html file, choose the paper size, and get a PDF back. The HTML is rendered and converted on your own device.

  • Free
  • No sign-up
  • No watermark
  • Runs in your browser

Selectable text keeps real text and working links, using standard PDF fonts. Exact look captures each page as a picture: use it for non-Latin scripts, emoji, web fonts or very complex designs.

0%

Quick facts

The code you paste never leaves this tab and is not sent to our servers. See What on-device processing means and our Privacy Policy.

Make a PDF from HTML without installing anything

HTML is a handy way to lay out a polished document: an invoice template, a newsletter, a printable flyer, a résumé you coded yourself. The people receiving it, though, usually expect a PDF. This converter takes the markup you supply and produces PDF pages right on your computer, with no command-line tools or headless browser to configure.

What happens when you convert

The first thing the tool does is remove every <script> element and inline event attribute (onclick, onload and the like), so none of the code can run. On Convert to PDF, your own browser lays out the cleaned HTML in a hidden, sandboxed frame exactly as wide as your page minus its margins (1 pt = 1.333 CSS px, so 16 px text becomes 12 pt). Because the browser does the layout, flexbox, grid, tables and floats keep their positions.

In Selectable text mode (the default), the tool measures where every word landed and writes it into the PDF as real text, in the closest standard PDF font (sans-serif becomes Helvetica, serif becomes Times, monospace becomes Courier, with bold and italic kept), at the same size and color. Background colors, borders, underlines, list bullets, <hr> lines and images are drawn in place, and links to http, https and mailto addresses become clickable. Pages are split so a line of text is never cut in half; page-break-before/after: always (or break-before: page) starts a new page, and table rows, images and break-inside: avoid blocks shorter than a page are kept together.

In Exact look mode, html2canvas captures the same layout as a picture at twice screen resolution and each page is an image. It looks closer to the browser for web fonts and unusual CSS, but the text cannot be selected or searched and links do not work.

With Add page numbers ticked, a small gray “Page 1 of 3” label appears centered at the bottom of every page. The finished file downloads as output.pdf. Preview shows the cleaned HTML at the same content width, but always open the download to confirm.

Content that converts cleanly

Content that causes trouble

Ways people use it

Tips for a cleaner result

Convert HTML to PDF in four steps

  1. Bring in the HTML. Paste markup into the editor box, or press Upload HTML file and choose an .html or .htm file.
  2. Set up the page. Pick the output (Selectable text or Exact look), paper size, orientation and margin, and tick Add page numbers if you need them.
  3. Check the preview. Press Preview to view the cleaned markup in a sandboxed frame at your page’s content width and correct anything that looks off.
  4. Create and review. Press Convert to PDF. The file saves as output.pdf; open it and look through every page before you send it.

HTML to PDF questions

Can I type in a website address to convert a live page?

No. The tool only works with HTML you paste or open from a file. To keep a copy of a live web page, open it in your browser, choose Print and pick Save as PDF.

Why do my images show up blank in the PDF?

Browsers usually block pictures pulled from other websites, and relative image paths have nothing to point to because only the HTML file itself is loaded. Putting the images into the HTML as data URLs gets around both problems.

Will the text in the PDF be selectable, and will links work?

Yes, in the default Selectable text mode. Text can be selected, copied and searched, and links to http, https and mailto addresses are clickable. In Exact look mode each page is an image, so neither works.

Why does my PDF use a different font?

Selectable text mode writes text with the standard PDF fonts: sans-serif fonts become Helvetica, serif fonts become Times and monospace fonts become Courier, with bold and italic kept. Each word stays where the browser placed it. To keep a web font’s exact look, choose Exact look (image).

Why do some characters show as a question mark?

The standard PDF fonts only cover Western European characters. Non-Latin scripts such as Chinese, Arabic or Hindi, emoji and some symbols become “?” in Selectable text mode. Choose Exact look (image) to keep them as they appear.

Is the JavaScript in my HTML executed?

No. Script elements and inline event handlers are stripped out before the preview or the conversion, so only static HTML and CSS are drawn.

What paper sizes are available?

Letter, Legal and A4, each in portrait or landscape, with margins anywhere from 0 to 200 points (72 points is 1 inch). The menu starts on US Letter.

Is there a way to number the pages?

Yes. Tick Add page numbers before converting and each page gets a small “Page 1 of 3” style label centered at the bottom.

Does my HTML get uploaded during conversion?

No. Cleaning, rendering and converting all happen in your browser, and your code is not sent to our servers. There is no charge, sign-up or watermark.