Quick answer
To convert HTML to PDF, choose a mode. Web page URL: enter the address, pick a desktop or mobile layout and click Convert to PDF; the page is captured in a real browser and split over A4 pages. HTML code: paste your HTML and CSS, check the live preview, choose A4, US Letter or Legal, portrait or landscape and a margin, then download. Long content flows onto as many pages as needed.
- Modes:
- Web page URL or HTML code
- Page sizes:
- A4, US Letter, Legal
- Orientation:
- Portrait or landscape (HTML code)
- Margins:
- Adjustable in millimetres
- Layouts:
- Desktop or mobile (URL mode)
- Preview:
- Live preview of your HTML
- Output:
- Image-based PDF pages
- Account:
- Not required
HTML is how the web is built, but sometimes you need a fixed document instead of a live page: an invoice generated by your app, a report built with HTML tables, a certificate template, an email newsletter to archive, a receipt, or a snapshot of a web page to attach to a ticket or send to someone offline. PDF is the universal format for that — it looks the same everywhere and prints properly.
Our HTML to PDF converter works in two ways. In URL mode, you enter a web address; the page is loaded in a real Chrome browser, captured from top to bottom in desktop or mobile layout and placed onto A4 pages. In HTML code mode, you paste your own HTML and CSS; a live preview shows exactly how it renders, and the converter draws it in your browser and lays it out on A4, Letter or Legal pages with your chosen orientation and margins.
Content longer than one page is automatically split across as many pages as needed. Scripts in pasted code are removed for safety, so only your markup and styles are rendered.
The HTML code mode runs entirely in your browser — handy for invoices and reports that contain customer data.
How to convert HTML to PDF – step by step
- 1 Choose the modeWeb page URL to capture a live page, or HTML code to convert your own markup.
- 2 Enter your contentPaste the URL, or paste your full HTML document including <style> rules into the editor.
- 3 Set the optionsFor URLs, choose desktop or mobile layout. For code, choose page size, orientation and margin, and check the live preview.
- 4 ConvertClick Convert to PDF. URL captures take 10–30 seconds; HTML code converts in a moment.
- 5 Download and checkThe PDF downloads automatically. Open it to check page breaks and margins.
Why use this HTML to PDF converter?
URL or code
Capture live pages or convert your own HTML and CSS.
Live preview
See your HTML rendered before converting.
Standard page sizes
A4, US Letter and Legal in portrait or landscape.
Custom margins
Set the white space around the content in millimetres.
Automatic pagination
Long pages flow over as many PDF pages as needed.
Free and simple
No account, no watermark, no software.
URL mode vs. HTML code mode
| Web page URL | HTML code | |
|---|---|---|
| Input | Any public web address | Your own HTML and CSS |
| Rendering | Real Chrome browser via Google Lighthouse | Your browser |
| Layout | Desktop or mobile | A4, Letter or Legal; portrait or landscape |
| Best for | Archiving and sharing existing pages | Invoices, reports, certificates, templates |
| Privacy | The URL is sent to Google to load the page | Processed locally |
How the PDF is made
Both modes create the PDF from a rendered image of the content: the page is drawn exactly as a browser displays it, then sliced into page-sized sections and placed into the PDF. This keeps fonts, colours, backgrounds and layouts looking identical to the screen. The trade-off is that text in the PDF is part of the image, so it cannot be selected or searched. If you need selectable text, run the result through PDF OCR, or print the page from your browser with "Save as PDF", which keeps live text.
Writing HTML that converts well
- Include your styles — put CSS in a <style> tag in the head or inline. External stylesheets and fonts may not load.
- Use a fixed width — a container of about 700–800 pixels maps nicely to A4 portrait; use wider for landscape.
- Use web-safe fonts — Arial, Helvetica, Georgia, Verdana or system fonts render reliably.
- Embed images — use data URIs from our Image to Base64 tool so images always appear.
- Avoid scripts — JavaScript is stripped; generate the final HTML before pasting.
- Plan page breaks — long tables and images may be split between pages; leave space or shorten sections.
Common uses
- Invoices and receipts generated by your web app or e-commerce store. For a ready-made layout, try our Invoice Generator.
- Reports built with HTML tables and charts.
- Certificates and tickets designed in HTML templates.
- Email newsletters archived as PDF for records.
- Web page snapshots to attach to support tickets, legal records or offline reading.
- Documentation exported from HTML help pages.
Capturing live web pages
URL mode is the quickest way to save a web page as a multi-page PDF. The page is loaded fresh as a first-time visitor, so cookie banners may appear. Choose the mobile layout for narrow, easy-to-read pages, or desktop to preserve the full design. Pages behind a login cannot be captured. For a single tall image instead of A4 pages, use the Website Screenshot tool.
Cleaning up the PDF
After converting, you can remove unwanted pages (such as a cookie banner page or footer) with Remove PDF Pages, add page numbers with PDF Page Numbers, combine several converted pages with Merge PDF and shrink the file with Compress PDF.
HTML to PDF for developers
Developers often need PDFs from HTML templates: order confirmations, statements, delivery notes and reports. This tool is ideal for designing and testing those templates. Paste the template with sample data, adjust the CSS until the preview and the PDF look right, and then reuse the same HTML in your application. For production systems that create thousands of PDFs automatically, a server-side renderer such as a headless browser is usually the better long-term choice, because it can keep text selectable and run without a person clicking a button. Still, prototyping here first saves a lot of trial and error. Keep your template tidy with the HTML Minifier for production, and check any JSON data you feed into it with the JSON Formatter.
Choosing page size and orientation
A4 (210 × 297 mm) is the standard paper size in most of the world, including Europe, Asia, Africa and Australia. US Letter (8.5 × 11 inches) is used in the United States, Canada and parts of Latin America; Legal (8.5 × 14 inches) is common for American legal documents. Choose portrait for text documents, letters and invoices, and landscape for wide tables, dashboards and certificates. Margins of 10–15 mm look clean on screen and leave room for printers that cannot print to the edge.
Privacy
In HTML code mode, your markup is rendered and converted inside your browser and never uploaded — safe for invoices and reports with personal data. In URL mode, only the address you enter is sent to Google's PageSpeed service to load and capture the page.
Troubleshooting
- Styles or images are missing. Use inline CSS and embedded or absolute image URLs. Some external resources block cross-site loading.
- Content is cut at page edges. Reduce the container width or switch to landscape.
- "Could not capture this page". The site may block automated browsers or be offline. Try again or use HTML code mode.
- The PDF is large. Image-based PDFs grow with page count; compress the result with Compress PDF.
Frequently asked questions
How do I convert a web page to PDF?
Choose Web page URL, enter the address, pick desktop or mobile and click Convert to PDF.
Can I convert my own HTML code?
Yes. Choose HTML code, paste your HTML and CSS, check the preview and convert.
Which page sizes are supported?
A4, US Letter and Legal, in portrait or landscape for HTML code.
Is the text in the PDF selectable?
No. Pages are rendered as images to look exactly like the screen. Use PDF OCR if you need selectable text.
Does JavaScript run in my HTML?
No. Scripts are removed for security; paste the final rendered HTML.
Is my HTML uploaded?
No. HTML code mode runs entirely in your browser.
Can I convert pages that need a login?
No. Only public pages can be captured in URL mode. Copy the page's HTML into code mode instead.
Why are some images missing?
External images may block cross-site loading. Embed them as Base64 data URIs.
Can I set margins?
Yes. Set the margin in millimetres in HTML code mode.
Is this converter free?
Yes. No account, no watermark.
Does it work on mobile?
Yes. Both modes work in mobile browsers; editing long HTML is easier on a computer.
Can I convert an HTML file?
Open the .html file in a text editor, copy its contents and paste them into HTML code mode.
Last updated November 21, 2026 · Written and tested by the SmallEasyTools team.