PDF Tools

HTML to PDF Converter

Paste HTML code and convert it to a downloadable PDF. Runs entirely in your browser.

How it works

The HTML is rendered exactly as a browser would display it, then captured onto an A4 page. Inline styles and basic CSS work well; content that relies on external stylesheets, fonts, or scripts loaded from other sites may not render since nothing is fetched from a server.

Common uses

  • Turning a styled HTML snippet or email template into a shareable PDF
  • Quickly generating a simple PDF from a snippet of markup

How the page is built

The HTML is placed in a hidden 700-pixel-wide area of this page, drawn, and fitted onto an A4 portrait page with 20-point margins, which scales it by about 0.79 (555 ÷ 700). Text set at 16 pixels therefore comes out at roughly 12.7 points. Content that runs past one page continues on the next, and the cut is made at a fixed height, so it can fall through a line of text or an image.

Why headings and lists can look plain

Because the markup is rendered inside this site, the site's base styles are active. Headings may not appear larger, bullet and numbered lists may lose their markers, and table borders may be missing unless your HTML sets them. The starter example uses inline styles for that reason. Write explicit styles for anything that matters, such as font-size on headings and border: 1px solid on table cells.

Safety and output

  • Scripts in the pasted code do not run, but other active markup, such as inline event attributes, could. Paste only HTML you trust.
  • The result is saved as document.pdf. The pages are drawn rather than typeset, so the text in the PDF may not be selectable or searchable.
  • Remote images, web fonts and linked stylesheets depend on the other site's settings and are often missing. Use inline styles and embedded (data URL) images for reliable results.

Frequently asked questions

Can I convert a live web page by entering its URL?

No — this tool only converts HTML code you paste in directly. Fetching a URL's content client-side isn't reliably possible for arbitrary sites due to browser cross-origin restrictions.

Why didn't my external stylesheet or font show up?

Content that depends on files from other sites, such as linked stylesheets, web fonts and remote images, may not load or may be blocked by the other site's cross-origin settings. Use inline styles and embedded images for reliable results.

Why do my headings and bullet lists look plain in the PDF?

The HTML is drawn inside this site's own page, so its base styles can override browser defaults. Add explicit styles, such as font sizes for headings and borders for table cells, to get the look you want.

Will JavaScript in my HTML run?

Script tags don't run, but only paste markup you trust, because it is inserted into this page while the PDF is generated.

Is the text in the PDF selectable?

It may not be. The page content is drawn into the PDF rather than written as text, so selecting and searching can be limited.

Related tools