PDF7 min readUpdated 2026-07-01

How to Convert HTML to PDF

Tools mentioned in this guide

You have HTML — an email template, an invoice you built with code, an exported report, a snippet from a web page — and you need it as a PDF you can send, print, or archive. PDF freezes the layout so it looks the same on every device, which is exactly why people convert HTML to it.

This guide covers the fastest free way to do it, plus the two situations where a different method is genuinely better: when you need the PDF's text to stay selectable and searchable, and when your document runs to many pages. If you just want it done now, paste your markup into the free HTML to PDF converter — it renders and converts entirely in your browser, so your code and content are never uploaded to a server.

The Fastest Way: Convert HTML in Your Browser

The FileNaut converter is built for one job — take HTML markup, show you exactly how it will look, and hand you a PDF. Here is the whole process:

  1. Open the HTML to PDF tool.
  2. Paste your HTML into the HTML Input box on the left. This is markup — tags like <h1>, <p>, <table>, and inline style="..." attributes — not a website address.
  3. Watch the Preview panel on the right. It renders your HTML live, so what you see is what the PDF will contain.
  4. Click Convert to PDF. Your browser builds the file and downloads converted.pdf automatically.

There is no signup, no watermark, and no upload. Every step runs as JavaScript inside your own browser tab, which is why it works offline once the page has loaded and why your content never touches a server.

What This Method Is Best For (and What It Isn't)

The browser converter captures your rendered HTML as a high-resolution image and drops it into a PDF page. That approach has real strengths and two honest limits worth knowing before you rely on it:

It's great for: short, self-contained documents — an invoice, a certificate, a one-page report, a styled email, a coupon, a résumé block. Anything that fits on roughly one page and where you care about the layout looking pixel-perfect.

Two things to know:

  • The text becomes part of an image. Because the page is captured visually, you can't select, copy, or search the words in the resulting PDF. If you need selectable, searchable text, use the Print-to-PDF method in the next section instead.
  • It fits to a single page width. Very long HTML is scaled to the page and content past the bottom can get cut off. For multi-page documents, Print to PDF or a code-based tool will paginate properly.

None of this requires uploading anything — a genuine advantage when the HTML contains a client invoice, salary figures, or anything you would rather not hand to a third-party server.

When to Use Print to PDF Instead (Keeps Text Selectable)

If you need the PDF's text to stay real text — selectable, searchable, copy-pasteable — or the document is long, your browser's built-in Print to PDF is the better tool. It renders HTML the same way the browser shows it and paginates automatically.

  1. Open the HTML file in your browser (double-click a saved .html file, or drag it into a browser tab). If you only have a snippet, save it as a .html file first.
  2. Press Ctrl + P (Windows) or Cmd + P (Mac).
  3. In the print dialog, set the destination to Save as PDF (Chrome/Edge) or PDF → Save as PDF (Safari).
  4. Under "More settings" you can turn Background graphics on to keep colours and shading, and toggle headers/footers off. Click Save.

The trade-off: Print to PDF respects your CSS and page breaks, but the exact look depends on your browser's print engine, which sometimes differs slightly from the on-screen view. Use the FileNaut converter when you want the capture to match the preview exactly; use Print to PDF when selectable text or multiple pages matter more.

For Developers: Convert HTML to PDF in Code

If you are generating PDFs on a schedule, from a server, or as part of a build, do it in code. The common options:

  • Puppeteer / Playwright (headless Chrome) — the highest-fidelity route. It renders the HTML in a real Chromium engine and exports a true, text-selectable, multi-page PDF.
    const browser = await puppeteer.launch();
    const page = await browser.newPage();
    await page.setContent(html, { waitUntil: 'networkidle0' });
    await page.pdf({ path: 'out.pdf', format: 'A4', printBackground: true });
    await browser.close();
  • wkhtmltopdf — a battle-tested command-line tool built on WebKit. Fast and simple for straightforward pages: wkhtmltopdf input.html output.pdf. Older CSS engine, so very modern layouts can render imperfectly.
  • WeasyPrint (Python) — great for print-oriented documents (invoices, reports) with strong CSS paged-media support: weasyprint input.html output.pdf.

Rule of thumb: for pixel-perfect fidelity and modern CSS, reach for a headless-Chrome tool (Puppeteer/Playwright); for lightweight batch jobs, wkhtmltopdf or WeasyPrint are lighter to run.

Tips for a Clean Result

  • Use inline styles for the browser converter. Since it captures a rendered fragment, styling applied directly with style="..." attributes is the most reliable way to control the look.
  • Keep it to one page for the image method. If your content is long, either split it into separate conversions or switch to Print to PDF for automatic pagination.
  • Host images somewhere permissive. Remote images only appear if their server allows cross-origin loading. For guaranteed results, embed images as Base64 data URIs directly in the HTML.
  • Preview first, always. The right-hand preview is your proof — if it looks right there, the PDF will match it. Fix layout issues in the HTML before you convert, not after.
  • Compress if it's heavy. High-resolution captures can produce large files. Run the result through the PDF compressor if you need to email it.

Related Conversions

Working in Markdown instead of raw HTML? The Markdown to PDF converter takes Markdown and produces a proper text-based PDF with real pagination. Need to shrink the file you just made? The PDF compressor gets it under email limits. Both run in your browser with no upload, same as the HTML converter.

Frequently Asked Questions

Is the HTML to PDF converter free?
Yes — completely free, with no signup, no watermark, and no upload. The HTML to PDF tool runs entirely in your browser, so there is no account to create and no server processing your content.
Can I convert a website URL to PDF with this tool?
Not directly — the tool converts HTML markup that you paste in, not a live web address. To save a whole webpage, open it in your browser and use Print to PDF (Ctrl/Cmd + P → Save as PDF), or paste the page's HTML source into the converter.
Will the text in the PDF be selectable?
With the FileNaut browser converter, no — it captures your rendered HTML as a high-resolution image, so the words are part of a picture and can't be selected or searched. If you need selectable, searchable text, use your browser's Print to PDF instead, or a code tool like Puppeteer.
Why does my long HTML get cut off in the PDF?
The browser converter fits your content to a single page width, so anything past the bottom of that page can be clipped. It's designed for short, one-page documents. For long documents that need multiple pages, use Print to PDF or a code-based converter, which paginate automatically.
Is my HTML uploaded anywhere?
No. All rendering and conversion happens in your browser using JavaScript — your HTML, and anything in it, never leaves your device. That makes it safe for invoices, reports, or anything containing private data.
My CSS doesn't look right in the PDF — how do I fix it?
The converter renders your HTML as a styled fragment, so inline styles (using the style="..." attribute) are the most reliable way to control the look. Check the live preview before converting — if it looks correct there, the PDF will match. For complex external stylesheets, Print to PDF or a headless-Chrome tool will render the CSS more faithfully.
What's the best way to convert HTML to PDF in code?
For the highest fidelity, use a headless-Chrome tool like Puppeteer or Playwright — they render in a real browser engine and output true, selectable, multi-page PDFs. For lighter batch jobs, wkhtmltopdf or Python's WeasyPrint are simpler to run. Pick headless Chrome when modern CSS accuracy matters most.

Ready to try it?

Use the tool right now — free, no signup, no upload.