HTML to PDF Converter
Turn raw HTML markup into a paginated PDF with a live preview, custom margins, headers, footers, and page numbers. Renders your HTML safely in a sandboxed frame before conversion. This HTML to PDF converter is free and needs no signup.
Why this converter renders your HTML in a hidden iframe before capturing it
Turning arbitrary HTML into a PDF is really a two step trick: paint the markup exactly as a browser would render it, then photograph that rendered layout and lay the photograph into a PDF page. This HTML to PDF converter does the painting in a sandboxed iframe with its own document, and does the photographing with html2canvas, then slices that image into PDF pages with jsPDF, moving each page cut into a blank gap so lines of text are not split. Both steps run in your browser. The HTML you paste or upload never leaves the page.
Why an iframe, specifically
An earlier version of this approach captured content sitting directly on the main page and produced blank PDFs. html2canvas renders the entire page and then crops down to your target element's bounding box, a documented behavior of the library. The fix was to build a completely isolated iframe with its own srcdoc document containing only the HTML being converted, positioned at true document coordinate (0,0) with position:absolute rather than position:fixed, and to force window.scrollTo(0,0) right before capture so the crop always lands in the right place regardless of how far down the page the visitor had scrolled.
allow-same-origin, and loaded with your HTML via srcdoc. An opaque overlay covers it so you never see the raw unstyled flash. <img> inside the rendered document is checked for .complete, and the tool waits for load or error events on any that are not finished, capped at a 4 second timeout so one dead image link cannot hang the conversion indefinitely. Options and their effect on the raster capture
| Option | What it changes |
|---|---|
| Scale | html2canvas's device pixel multiplier; higher scale means a sharper but larger capture |
| Background | Prints or drops background colors and images, like the matching option in a browser print dialog |
| Margin | None, normal (0.5in) or wide (1in), applied as jsPDF page margin around the image |
| Allow scripts | Adds allow-scripts to the iframe sandbox, letting pasted JavaScript run before capture |
| Page numbers | Draws real vector text via jsPDF, independent of the rasterized content |
Live preview
A separate sandboxed iframe mirrors your input as you type, debounced by 350ms, so you can check the markup before spending time on a full conversion.
File upload
An .html file can be loaded directly with FileReader.readAsText(), populating the same textarea the paste option uses.
Rendering engines and specs
- html2canvas documentation explains the whole-page-then-crop rendering model this HTML to PDF converter works around.
- jsPDF documentation covers the PDF assembly API used for text, pages and page sizing.
- MDN iframe sandbox attribute documents the
allow-same-originandallow-scriptsflags this HTML to PDF converter sets conditionally. - ISO 32000-2 is the PDF 2.0 specification underlying the output file format.
Documents people generate this way
Archiving an email template or landing page as a fixed document, generating a printable invoice from a small HTML snippet, converting an internal report built as an HTML fragment into something you can attach to an email, or producing a quick PDF preview of a web component during development without setting up a headless browser toolchain.
FAQ: HTML to PDF Converter
No. Browsers do not let one website read the pages of another, so there is no URL option. Open the page, view its source (Ctrl + U in most browsers) or save it as an .html file, then paste or upload it here. Images and stylesheets only load if their addresses are full https links.
Yes. Both inline styles and style tags included in your HTML render exactly as a browser would display them, since the conversion uses an actual browser rendering pass rather than a simplified parser.
Yes. Enter text in the Header Text and Footer Text fields in Page Settings, and leave Add Page Numbers checked. All three are stamped onto every page of the resulting PDF.
Your markup is rendered inside a sandboxed iframe with scripting restricted, so the HTML to PDF converter focuses purely on visual layout, fonts, colors, and structure, rather than running arbitrary code.
No. Rendering and PDF generation both happen locally in your browser. Only images or stylesheets your HTML links to are fetched, by your own browser, from wherever they are hosted.