HTML to PDF Converter

Convert HTML code to a PDF document. Paste HTML or upload a file, preview the result, customize page size and margins, then download.

Runs in your browser. No data leaves your device.

About this tool

Converts pasted or uploaded HTML into a downloadable PDF with a choice of page size, orientation, margins and render quality. It shows a paginated preview first so you can see where pages break. The PDF is built by rasterizing the rendered HTML with html2canvas and placing the images on pages with jsPDF.

Features
  • Two input modes: paste HTML in a code textarea or upload an .html/.htm file (up to 5 MB)
  • Full documents are parsed with DOMParser: <style> blocks and stylesheet links (by href only) are kept, and body/html CSS rules are applied to the page wrapper
  • Live paginated preview in a Shadow DOM (isolated from site CSS), with page shadows and "n / total" page labels
  • Honors forced page breaks: break-before/break-after: page and page-break-before/page-break-after: always, in both the preview and the PDF
  • Page sizes A4 (210 x 297 mm), Letter (216 x 279 mm), Legal (216 x 356 mm); portrait or landscape
  • Margins None, 5, 10 or 20 mm; quality 1x, 2x (default) or 3x render scale
  • html2canvas and jsPDF are loaded only when you first click Download PDF
  • Clear button resets the input
How to use it
  1. Paste HTML or switch to Upload File and choose an .html file
  2. Check the paginated preview
  3. Choose page size, orientation, margin and quality
  4. Click Download PDF to save document.pdf
Inputs
  • HTML text (fragment or full document) or an .html/.htm file up to 5 MB
Outputs
  • document.pdf where each page is a JPEG image (quality 0.95) of the rendered HTML at 96 DPI times the chosen quality scale
Limits and notes
  • The PDF is image-based: text is not selectable or searchable and links are not clickable
  • Pages are cut at fixed heights unless you add CSS page breaks, so lines or images can be split across pages
  • Output reflects what html2canvas can render; some CSS may differ from a real browser render
  • The HTML is sanitized with DOMPurify and rendered in a sandboxed frame, so scripts and event handlers (onclick, onerror...) never run; the preview and the PDF use the same sanitized markup
  • The site's security policy blocks most external stylesheets, fonts and images, so inline your CSS and use data: images for reliable output
  • The converter waits for fonts plus 300 ms before capturing; slow external resources may be missed
  • Settings and input are not saved (no localStorage)
  • Processing is local; your HTML is not uploaded to Overtooled

Frequently Asked Questions

How does the HTML to PDF Converter work?

The tool sanitizes your HTML with DOMPurify and renders it in a hidden, sandboxed iframe where scripts and event handlers cannot run, then uses html2canvas to rasterize the rendered DOM into a canvas bitmap. The jsPDF library takes that canvas image and places it onto PDF pages at the configured size (A4, Letter, Legal). For multi-page content, the tool slices the canvas into page-height sections and adds each as a separate PDF page with your configured margins.

What page sizes are supported?

A4, US Letter, and Legal. You can choose portrait or landscape orientation and set margin size.

Why does the PDF look different from my HTML?

The conversion rasterizes your HTML via html2canvas. Complex CSS features like CSS Grid, animations, and media queries may render differently than in a browser.