Convert to PDF

HTML to PDF — convert code and pages into a document

Paste HTML, an invoice template or a code snippet and get a properly laid out PDF with selectable text. Headings, bold, italic, lists, tables, quotes and code blocks are all handled inside your browser.

No upload Files stay in your browser Free, no signup Works offline

How to convert HTML to PDF

Paste your HTML

Type or paste the markup, or load an .html file. A sample invoice is one click away if you want to see what is possible.

Adjust the layout

Choose the page size and orientation, set a base text size and margin, and decide whether you want page numbers.

Convert and download

Press “Convert HTML to PDF”. The result has real text, so it stays sharp and searchable.

Only inline data: images are embedded. External images are skipped, because fetching them would require a server — and this tool deliberately has none.

Features

Proper element support

Headings, paragraphs, lists, tables, blockquotes, horizontal rules, preformatted code and links.

Selectable text output

Layout is written as real PDF text, so it stays crisp and can be searched — not a screenshot.

Tidy tables

Real table rows with shaded headers and clean cell borders, sized to fit the page width.

Plain-text mode

Paste raw text with angle brackets in it and switch to plain-text mode to have the tags shown literally.

Nothing leaves the browser

Parsing happens with the browser’s own DOMParser, locally. Your templates and data are never uploaded.

Free, no watermark

No signup, no page limit, no branding added to your document.

Why convert HTML to PDF at all

HTML is the most flexible way to describe a page, which is why invoices, reports, receipts, statements and tickets are so often generated as HTML. But HTML is not a document. It reflows with the window, it depends on fonts and stylesheets that may not be available later, and it cannot be signed, numbered or filed.

PDF is the opposite: a fixed page with measured text positions, a page count, and the same appearance on every device. Converting between the two is what every billing system does, usually on a server. This tool does it in the browser instead, which is a genuine advantage when the HTML contains customer names, amounts or personal data.

It is also useful in the opposite direction from what you might expect: developers use it to turn code snippets, README files and API documentation into PDFs for review, and students use it to submit HTML assignments as printable documents.

What is supported, and what is not

Supported well: h1–h6 headings with proportional sizes, paragraphs, bold and italic, underlined text, ordered and unordered lists with markers, tables with header rows, blockquotes with a coloured bar, horizontal rules, pre and code blocks in a monospace font, links (rendered as underlined text, since a PDF viewer cannot follow them from inside the page), and line breaks.

Not supported, deliberately: CSS layout. Flexbox, grid, floats, absolute positioning and media queries have no meaning on a fixed page. If you need an exact visual replica of a complex styled page, the honest answer is to use the browser’s own print dialog and choose “Save as PDF” — it implements the full CSS specification because it is the same rendering engine.

Also not supported: external images. Fetching an image from a URL would require a network request through a server to avoid CORS problems, which contradicts the privacy design of this site. Images embedded as data: URIs are embedded normally; any other <img> is replaced by a short placeholder that names it.

Building a simple invoice template that converts cleanly

Start with an <h1> for the document title and a short paragraph with your company details, then a <hr>. Metadata such as invoice number and date belongs in a paragraph with bold labels. The line items go in a <table> whose first row uses <th> cells for the column headings — those are shaded automatically.

Keep columns to four or five. The converter divides the page width equally between cells, so a table with ten columns produces very narrow, hard-to-read content. Put the total in a bold paragraph after the table rather than in another table row, and use a blockquote for payment terms — it renders with a coloured left bar that draws the eye.

If the invoice is long, page numbers appear automatically at the bottom centre, which is what accountants expect. And because the text is real, the PDF can be searched for an invoice number later, which is not true of HTML converted through a screenshot-based service.

Code snippets, documentation and plain text

Wrapping code in <pre> gives it a light grey background, a monospace font and preserved whitespace, which is what makes code readable in a PDF. Individual lines may still wrap if they are very long, so keep the base text size small — 9 or 10 points — for wide code.

For escaping, remember that literal angle brackets must be written as &lt; and &gt;, and ampersands as &amp;. If you would rather not escape anything, tick “Treat my input as plain text” and the converter will show the tags literally, converting line breaks to <br> for you. That is the quickest way to make a PDF out of a diff, a log file or a message that happens to contain angle brackets.

One practical tip for both: the base text size and page margin have a bigger effect on the final document than any other setting. Narrow margins with 9 point text fit roughly twice as much content per page, which is exactly what you want for documentation and exactly what you do not want for a client-facing invoice.

Frequently asked questions

Do I need to know HTML to use this?

No. Click “Insert a sample invoice” to load a working template and edit the text inside it. If you have plain text with no tags at all, tick “Treat my input as plain text” and it will still produce a tidy PDF.

Is the text in the output selectable?

Yes. The layout is written as real PDF text using embedded fonts, so it stays sharp at any zoom level and can be searched. It is not a screenshot of the page.

Can I use CSS to style my HTML?

Inline styling for text colour and size is honoured for simple cases, but full CSS layout — flexbox, grid, positioning — is not supported, because on a fixed page those properties have no meaning. For pixel-perfect CSS rendering, use your browser’s own Print → Save as PDF.

Why is my external image missing?

External images are intentionally not downloaded, because fetching them would require a server and break the privacy promise of this tool. Convert the image to a data: URI, or use the Images to PDF tool to put pictures on pages.

Can I convert a whole .html file?

Yes. Use the file picker in the extra controls to load an .html file, edit it if you want, and convert. Stylesheets linked with <link> are ignored, but inline styles and semantic tags work.

Does it handle tables properly?

Yes — rows, header cells with shading, column separators and automatic row heights. Keep tables to about five columns to stay readable on A4.

Can I add page numbers?

Page numbers are added at the bottom centre automatically when the document is longer than one page, and you can turn them off with a checkbox.

Written and maintained by the PDFUtilise team. Last reviewed: 2026-10-07. Found a problem with this tool? Tell us — we fix reported bugs fast.