HTML to PDF: Code In, PDF Out
Paste HTML with CSS or formatted text, check the live preview, and download a PDF in A4, Letter or Legal. It is made in your browser.
Rate this toolHTML to PDF Studio
HTML or rich text · A4, Letter, Legal · margins and quality · live preview
Your content
Full HTML with a style block or inline CSS works. Images from other sites may not show.
Page size
Orientation
Margin
Quality
Preview and PDF
- Page sizes
- 3Page sizes
- Quality levels
- 3Quality levels
- Input modes
- 2Input modes
- Files uploaded
- 0Files uploaded
Finish your PDF
Tools that pick up where this one leaves off.
Turn HTML into a PDF in three steps
From a snippet of HTML or some formatted text to a PDF file: no sign-up, no upload, no watermark.
- STEP 01
Add your content
Paste HTML with its style block, or type and paste formatted text.
Scripts are removed - STEP 02
Pick the layout
A4, Letter or Legal, portrait or landscape, a margin and a quality.
Live preview on the right - STEP 03
Convert
The PDF is drawn on your device and downloads straight away.
Name it before you save
How to use this HTML to PDF converter
html2canvas draws your HTML as a picture at the page's width, and jsPDF cuts that picture into pages.
- 1
Paste or type
Paste HTML mode takes a full page or a fragment. Rich text mode takes formatted text from a document.
- 2
Watch the preview
The preview shows your HTML in a locked-down frame, so you can check it before converting.
- 3
Choose the page
Page size and margin set the width your HTML is drawn at, like a browser window that size.
- 4
Convert and save
Long content runs onto as many pages as it needs. Type a file name first if you like.
Getting a clean PDF from HTML
Four habits that make the PDF match what you expect.
Keep CSS in the HTML
A style block or inline styles travel with the code. Linked stylesheets may not load.
- Style block in the head
- Inline styles work
- Avoid external CSS files
Embed your images
Images from other sites only draw if that site allows it. Data URIs always work.
- Base64 logos
- Same-site images
- Check the preview
Design for the page width
A4 portrait with 20 mm margins is about 643 CSS pixels wide. Wide layouts get squeezed.
- Use max-width 100%
- Avoid fixed wide tables
- Try landscape
Leave room at page edges
Pages are cut at fixed heights, so a line can split across two pages.
- Shorter blocks
- Check the last page
- Adjust spacing
What comes through, and what doesn't
html2canvas reads the page's DOM and styles. It is not a full browser print engine.
Text and fonts
Headings, paragraphs and lists, in the fonts your browser can show.
Colours and boxes
Backgrounds, borders, padding and most layout from your CSS.
Images
Embedded images and same-site images. Others need the site to allow it.
No scripts
Scripts, iframes and event handlers are removed before drawing.
No print CSS
The page is drawn as it looks on screen, so @media print and @page rules don't apply.
Pages are pictures
Each PDF page is a JPEG image, so its text can't be selected or searched.
How different people use it
One studio, very different documents.
Freelancers
Turn an invoice template into a PDF to email to a client.
Developers
Check how a snippet or email template looks on paper without setting up a server.
Writers
Paste formatted text from a document and save it as a PDF to share.
Job seekers
A good-looking PDF for people to read. For job portals that scan text, export a text PDF too.
What the studio can and can't do
Straight from the tool, so you know before you start.
Input
What you can put in.
- Pasted HTML with CSS
- Formatted rich text
- Style blocks, scoped safely
- Embedded images
Output
What you get back.
- A4, Letter or Legal
- Portrait or landscape
- Margins of 0, 10 or 20 mm
- As many pages as needed
Not supported
Things to know first.
- Converting a web address
- Selectable text in the PDF
- Print CSS and page break rules
- Running JavaScript
PDF too large to email? Shrink it with Compress PDF.
Keeping your HTML templates reusable
Habits for when you make the same kind of PDF often.
- 1
Keep one template
Save your HTML in a file. Paste it, change the details, convert.
- 2
Name each PDF
Type a name like invoice-042 in File name so downloads don't overwrite each other.
- 3
Embed the logo
Put the logo in the HTML as a data URI so it always renders.
- 4
Note the settings
Write down the page size, margin and quality that look right for that template.
This studio vs your browser's Print to PDF
Both make a PDF from HTML. They work in very different ways.
| Feature | HTML to PDF studio | Browser Print to PDF |
|---|---|---|
| Works on pasted code | ✓ Yes | Open it as a page first |
| Scripts stripped | ✓ Always | Page runs as normal |
| Text in the PDF | ✗ Picture of text | ✓ Selectable text |
| Print CSS (@media print) | ✗ Not used | ✓ Used |
| Same look on every device | ✓ One fixed width | Depends on printer settings |
Pro tips for HTML to PDF
Small checks that save a second conversion.
Preview first
If something looks wrong in the preview, it will look wrong in the PDF.
Wide table?
Switch to landscape for more width before you convert.
File too big?
Pick Standard or Draft. High draws at 2x for the sharpest text.
Missing logo?
The image site blocked it. Embed the logo as a data URI instead.
Line cut in half?
Add a little space above that block, or change the margin, and convert again.
Need copyable text?
Open the HTML in a browser tab and use Print, then Save as PDF.
Private content
Invoices and contracts are drawn on your device and never uploaded.
PDF to HTML?
Going the other way? Try PDF to HTML.
Your HTML is laid out at the page's width minus the margins, about 643 pixels for A4 portrait with 20 mm margins. A layout that looks good in a phone-sized window will look good in the PDF.
Paste HTML, or use Rich text?
Code gives you control. Rich text is quicker for copied documents.
Paste HTML
Full control with your own style block, classes and layout. Best when the look matters.
When you have the code
Rich text
Type or paste formatted text and keep its bold, lists and headings, with no code at all.
When you have a document
Who uses this HTML to PDF converter
The same studio, six everyday jobs.
Invoices
An HTML invoice template as a PDF.
Email templates
A newsletter design saved for sign-off.
Resumes
An HTML resume as a PDF to read and print.
Notes
Formatted notes as a file to share.
Developer previews
A snippet's printed look, in seconds.
Printouts
Content on A4 or Letter for printing.
Need images in a PDF instead? Try JPG to PDF.
Frequently asked questions
Quick answers about CSS, images, page sizes and privacy.
Is the HTML to PDF tool free?
Is my HTML content safe?
What page sizes are supported?
Can I include CSS styles?
What people say
Reviews from people who used this tool.
Loading reviews…
Popular presets
Jump to a version of this tool already set up for a specific need.
More free PDF tools
Free, with no sign-up, just like this one.
- Free toolPDF to HTMLConvert PDF documents to clean HTML with text and heading extractionTry it now
- Free toolJPG to PDFCombine JPG, PNG, WebP, and other images into a single, clean PDF - page size, orientation, and margins of your choice.Try it now
- Free toolPDF to WordConvert PDF to editable Word with OCR, font detection, and page preview - 100% free, no signupTry it now
- Free toolPDF to PowerPointConvert PDF files to real .pptx slides: each page is rendered as a high-fidelity image so layout is preserved exactly (text isn't separately editable; use PDF to Word for that).Try it now
- Free toolPowerPoint to PDFConvert .pptx (PowerPoint 2007+) presentations to PDF: text + embedded images extracted per slide; layout, fonts, and animations are not preserved.Try it now
- Free toolPDF to ExcelExtract tables, financial data, and structured content from PDF documents into editable Excel spreadsheets (XLSX).Try it now