Home
Tools
Blog
Resources
About
Legal
Donate Get Started — Free
0 words · 0 chars
HTML Source
Live Preview
PDF Settings & Options
12px
40pt
1.4
100%
15%
#1a1a1a
#ffffff
Page Numbers
Auto Preview
Include Background
Generating PDF...
PDF generated successfully!
FREEConvert

HTML to PDF

Convert any HTML code to a pixel-perfect PDF. Full CSS support, live preview, custom page sizes, and web font embedding — all processed privately in your browser.

Full CSS Support Live Preview Web Fonts 100% Private
index.html
<html>
<body>
<h1>Hello World</h1>
<p>Welcome to PDFly</p>
</body>
</html>
output.pdf 24 KB
Features

12 powerful HTML-to-PDF features

Everything you need to convert HTML code to professional PDF documents — all in your browser.

Raw HTML Input

Paste any HTML code directly into the editor. Full support for HTML5 tags, semantic elements, forms, and embedded styles.

CSS Style Support

Inline styles, internal style tags, and external stylesheets are all supported. Flexbox, grid, and responsive layouts render correctly.

Live Preview

See your HTML rendered in real-time before generating the PDF. Make adjustments and preview changes instantly without regenerating.

Custom Page Size

Choose from A4, Letter, Legal, A3, A5, or set custom dimensions. Portrait and landscape orientations both supported.

Margin Control

Set precise margins in inches, centimeters, or millimeters. Use presets or define custom values for each side independently.

Header & Footer Injection

Add custom headers and footers with page numbers, dates, and titles. Use HTML templates for dynamic content on every page.

Image & SVG Rendering

Embedded images, base64 data URIs, and inline SVG graphics are rendered faithfully in the output PDF at full resolution.

Font Embedding

Web fonts from Google Fonts and other CDNs are embedded in the PDF. Your document looks the same on every device.

Print-Optimized Output

Colors are preserved, backgrounds are included, and page breaks respect CSS print media queries for professional results.

Batch HTML Conversion

Convert multiple HTML files or snippets in one session. Each gets its own PDF with consistent settings applied across all outputs.

HTML Sanitization

Scripts and potentially harmful elements are automatically removed for safety. Your PDF contains only visible content and styles.

100% Client-Side Processing

Your HTML code is rendered and converted in your browser. No uploads, no servers — perfect for proprietary templates and designs.

How it works

Convert HTML to PDF in 3 steps

Paste, configure, download — that's all it takes.

1

Paste your HTML

Enter your HTML code in the editor. Add inline CSS or use a style tag for styling. The live preview shows the rendered output.

2

Configure PDF settings

Set page size, margins, orientation, and headers/footers. Adjust until the preview looks exactly how you want the PDF to appear.

3

Generate & download

Click convert to generate the PDF instantly. Download immediately — no waiting, no watermarks, no limits.

Benefits

Why convert HTML to PDF with PDFly?

The fastest, most private way to turn HTML code into professional PDFs.

Instant Conversion

No need to open a browser, print to PDF, and crop. Paste HTML and get a pixel-perfect PDF in one click.

Developer-Friendly

Built for developers and designers. Test HTML templates, generate invoices from HTML, and convert prototypes to PDF.

Privacy for Proprietary Code

Your HTML templates and designs never leave your browser. Perfect for proprietary code, client work, and internal documents.

Pixel-Perfect Preview

See exactly how your HTML will look as a PDF before generating. No surprises, no wasted conversions, no rework.

Rich Media Fidelity

Images, SVGs, gradients, and web fonts are preserved in the PDF. The output matches your HTML design precisely.

Full Layout Control

Custom page sizes, margins, headers, footers, and orientation. Every aspect of the PDF page is configurable.

Use cases

Convert any HTML to PDF

From invoice templates to documentation — turn any HTML into a professional PDF.

Invoice Templates

Convert HTML invoice templates to PDF for emailing to clients. Dynamic data fills in automatically before conversion.

Email Templates

Test how HTML email designs look when printed. Generate PDF archives of email campaigns and newsletters.

Web Pages

Save web page designs, landing pages, and prototypes as PDF for client review and portfolio documentation.

Reports & Dashboards

Convert HTML-generated reports, analytics dashboards, and data visualizations to PDF for sharing and archiving.

Documentation

Turn HTML documentation pages into PDF manuals. Maintain formatting, code blocks, and internal links.

Receipts & Tickets

Generate PDF receipts, tickets, and confirmations from HTML templates for e-commerce and event systems.

Certificates

Convert HTML certificate designs to PDF with custom fonts, backgrounds, and borders for awards and diplomas.

Brochures & Flyers

Design marketing materials in HTML and export as print-ready PDFs with proper page sizes and margins.

Tips & best practices

Better HTML-to-PDF conversions

Pro tips for pixel-perfect PDF output from HTML.

1

Use Print CSS

Add a @media print block to your CSS to hide navigation, adjust colors for print, and set page breaks. This ensures the PDF looks clean and professional.

2

Test with Live Preview

Always check the live preview before generating. Look for content overflow, missing images, and broken layouts that need fixing.

3

Embed Fonts Explicitly

If using custom fonts, include them via Google Fonts or as base64 data URIs. This ensures fonts render correctly in the PDF even offline.

4

Set Page Breaks

Use CSS page-break-before or page-break-after properties to control where content splits across pages. Avoid awkward breaks in tables and lists.

5

Optimize Image Sizes

Compress images before embedding in HTML. Large base64 images slow down rendering and increase PDF file size significantly.

6

Use Relative Units

Use rem, em, and percentages instead of px for font sizes and spacing. This ensures content scales properly to the PDF page size.

Comparison

PDFly vs. other HTML-to-PDF tools

See how PDFly compares to popular alternatives.

FeaturePDFlywkhtmltopdfPuppeteerhtml2pdf.js
Client-side processing✓✗✗✗
No file upload required✓✗✗✓
No installation needed✓✗✗✓
Live preview✓✗✗✗
CSS print media support✓✓✓✗
Custom page sizes✓✓✓✓
Header & footer injection✓✓✓✗
Web font embedding✓✓✓✗
100% free✓✓✗✓

Your HTML code never leaves your browser

HTML to PDF runs 100% client-side. Proprietary templates, client designs, internal documents — everything is rendered and converted on your device. No servers, no tracking, no data collection.

Zero uploads
Zero tracking
Zero data stored
FAQ

Frequently asked questions

Yes, completely free with no daily limits, no file size caps, and no watermarks. Convert as many HTML documents as you need, anytime.
Full HTML5 support including semantic elements, forms, tables, lists, images, SVGs, and embedded media. CSS3 features including flexbox, grid, animations (first frame), and media queries are all supported.
You can include external stylesheets via link tags or @import rules. However, for best results and privacy, inline your CSS or use a style tag within the HTML. External resources load from their original servers.
For security reasons, JavaScript is disabled during conversion. The PDF captures the static HTML and CSS as-is. If your page relies on JavaScript for rendering, run the script first and paste the resulting HTML.
Yes. Images embedded as base64 data URIs or loaded from URLs are rendered in the PDF. Web fonts from Google Fonts and other CDNs are embedded directly in the PDF file for consistent rendering on any device.
Yes. Choose from standard sizes (A4, Letter, Legal, A3, A5) or set custom dimensions in inches, centimeters, or millimeters. Portrait and landscape orientations are both supported.
Absolutely. HTML to PDF runs 100% client-side. Your code is rendered and converted in your browser. Nothing is uploaded to any server — perfect for proprietary templates, client work, and internal documents.
Use CSS properties page-break-before, page-break-after, and page-break-inside to control where content splits. You can also use the break-before, break-after, and break-inside properties which are the modern equivalents.