Overview
Turns HTML into a PDF. Paste markup or load an .html file, see it on a sheet of the chosen paper size, and export a PDF with your margins and orientation. Scripts, frames, forms and event handlers are removed before anything is rendered, and remote images load only if you allow them. The PDF is created in your browser with html2pdf.js.
How It Works
Paste HTML into the editor or click Load .html file, and the preview on the right updates as you type. Choose the paper size, portrait or landscape, margins from 0 to 40 mm and a file name. CSS inside style tags is kept and scoped to the document. If any unsafe elements were removed, a note lists how many. Click Download PDF to render and save the file.
Step-by-Step Usage Guide
- Paste your HTML or load an .html file.
- Pick the paper size, orientation and margins.
- Allow remote images only if the page needs them.
- Check the preview and click Download PDF.
Technical Specifications & Standards
The input is parsed with DOMParser and cleaned with an allow-list sanitizer before it touches the page. Script, iframe, object, embed, form and similar elements are dropped, every attribute starting with on is removed, and links using javascript: or other unexpected schemes are stripped. CSS is kept, minus @import rules and expression() values, and is wrapped in an @scope rule so html and body selectors apply to the exported document without restyling the tool around it. Remote images, fonts and CSS backgrounds are blocked by default, because loading them would contact other servers; turn on Load remote images if you need them, and note that servers without CORS headers still cannot be drawn. Data URI images always work. html2pdf renders the content with html2canvas into page-sized images and assembles them with jsPDF, avoiding breaks inside table rows, images and pre blocks. Because each page is an image, its text is not selectable.
Targeted Use Cases
- Saving an HTML email template or invoice as a PDF attachment.
- Converting a generated HTML report into a document for printing.
- Making a PDF from a snippet of formatted content without a word processor.
- Previewing how an HTML layout looks on A4 or Letter paper.
Notes & Gotchas
- Embed images as data URIs so they appear without loading anything remote.
- Use CSS page-break-before or break-before rules to control where pages split.
- Print the preview to PDF from the browser instead when you need selectable text.
Frequently Asked Questions
How do I convert an HTML file to PDF?
Click Load .html file or paste the code, pick a paper size and margins, check the preview and click Download PDF. The file is created in your browser.
Why is the text in my PDF not selectable?
Each page is rendered as an image so the output matches the preview exactly. For selectable text, open the page in a browser and use Print, then Save as PDF.
Why are my images missing?
Remote images are blocked by default for privacy. Turn on Load remote images and fonts, or embed the images as data URIs. Servers that do not send CORS headers cannot be drawn.
Does JavaScript in my HTML run?
No. Scripts and event-handler attributes are removed before rendering, and the preview frame is sandboxed, so pasted code cannot run.
Related tools
- Markdown to PDF Converter - Convert Markdown or a GitHub README to PDF with code highlighting, Mermaid diagrams, math, page size, margins and a table of contents.
- HTML to Word (DOCX) Converter - Turn HTML into a Word .docx with headings, lists, tables, links and code kept as real Word styles. Scripts, styles and event handlers are removed first, and nothing leaves your browser.
- PDF to HTML - Convert a PDF's text to HTML: a reflowing page with real headings and paragraphs for the web, or a positioned layout that places each text run where it sat on the original page.
- HTML Formatter & Beautifier - Format messy or minified HTML with proper indentation. Copy production-ready markup instantly.
- Add Page Numbers to PDF - Stamp page numbers on a PDF in formats like "Page 1 of 9" or roman numerals, with position, size, margin and start number.
- PDF Page Splitter - Extract specific pages or page ranges from a PDF and download as a new file.