PDF Tools
HTML to PDF
HTML to PDF is part of Toolspire and is ready as soon as this page loads. Paste HTML or open an .html file, preview it at its printed width with page breaks marked, pick the page size and margins, and save a crisp PDF with selectable text — without uploading anything.
On this page
What you can do here
Real text, not a screenshot
The PDF is made by the browser’s print engine, so text is sharp at any zoom, can be searched and copied, and links work.
See page breaks first
The preview is drawn at the exact paper width and marks where each new page starts, so you can fix the layout before saving.
Invoices and templates
Ideal for HTML invoices, receipts, email templates, reports and resumes. Try the sample invoice to see how it works.
Clean page breaks
Images, table rows and code blocks move to the next page instead of being sliced across two.
Your page setup wins
The page size and margins you choose here override any @page rules in the HTML, so the PDF comes out as you expect.
Private and safe
Everything happens in this tab, and scripts in the HTML are blocked so pasted code can’t do anything unexpected.
The sequence
How to convert HTML to PDF
- 1
Add your HTML
Paste HTML into the editor, click Open file to load an .html file, or try the Sample invoice.
- 2
Set up the page
Choose the page size, orientation and margins, and check the preview and its page-break lines.
- 3
Save as PDF
Click Save as PDF. In the print window, set the destination to Save as PDF and turn off Headers and footers.
- 4
Download
Click Save and choose where to keep the PDF. Its name is taken from the file name box or the page’s title.
Worth knowing
- HTML to PDF on Toolspire: turns HTML code or an .html file into a PDF using your browser’s own print engine, so text stays selectable and searchable and links stay clickable.
- Works with a full page (with its own
<style>) or a fragment such as<h1>Hello</h1>, which gets clean default styling. - Page sizes A4, Letter, Legal, A3 and A5, portrait or landscape, with none, narrow, normal or wide margins.
- A live preview shows the page at its printed width, with dashed lines where the page breaks will fall.
- Keeps background colours, and can stop images, table rows and code blocks being cut in half across pages.
- JavaScript in the HTML is not run, for safety: pages that build their content with scripts need to be saved from the browser instead.
- The HTML never leaves your device — nothing is uploaded to a server.
Getting a perfect PDF
Use absolute links for images and styles. A relative link like images/logo.png only works if you set the Base URL to the site the HTML came from, for example https://example.com/. Images embedded as data: URLs always work.
Turn off headers and footers in the print window (under *More settings* in Chrome and Edge) to remove the date, title and page URL printed at the edges.
Force a new page anywhere by adding <div style="break-before: page"></div> to the HTML. Headings are kept with the paragraph that follows them.
For the most faithful result, use Chrome or Edge on a computer — they follow the page size and margins exactly. Other browsers work too but may ignore some print settings.
Which page size to choose
| Page size | Dimensions | Typical use |
|---|---|---|
| A4 | 210 × 297 mm | India, Europe and most of the world |
| Letter | 8.5 × 11 in (216 × 279 mm) | USA and Canada |
| Legal | 8.5 × 14 in (216 × 356 mm) | US legal documents and contracts |
| A3 | 297 × 420 mm | Posters, wide tables and diagrams |
| A5 | 148 × 210 mm | Booklets, receipts and small notices |
FAQ
Questions about HTML to PDF
Where does HTML to PDF run?
Is the text in the PDF selectable?
Why doesn’t my JavaScript run?
Can I convert a website URL to PDF?
Why are my images missing?
https:// addresses. Images on your computer must be embedded as data URLs.How do I remove the date and URL at the top and bottom?
Does it work on a phone?
Keep going
Related tools
Last updated Report a problem or suggest a feature