OnlineTextLab
Esc

HTML to PDF Converter

Pastes in as markup, comes out as a clean document.

0 characters

Structure that will go into the PDF

Paste HTML and see the headings, lists, tables and links that will be kept. Styling is not.

Page options

Page size

Orientation

Text size

Runs on your device. Your files and text are not uploaded.

About HTML to PDF

This tool suits HTML that holds content: a generated invoice, an exported email template, a report from a script, a fragment copied out of a content system. It reads the structure of the markup and produces a plain, well-set document with real text and working links.

It is important to know what it is not. It does not reproduce how a page looks in a browser. Your stylesheet, colours, fonts, columns and flexbox layouts are ignored on purpose. If you want a faithful copy of a designed web page, open that page and use your browser's own Print command with Save as PDF, which has the full rendering engine behind it.

How it works

Your markup first passes through a sanitizer: script, style, iframe, form and similar elements are deleted, and so are event handlers such as onerror and every style attribute. Nothing in your input runs, including in the live preview next to the text box. In a test, an img tag with an onerror handler and an inline script both failed to execute.

The tool then walks the remaining elements. Headings, paragraphs, nested lists, blockquote, pre, hr and table each become a drawn block. Bold, italic and code styling come from the tags themselves, such as strong, em and code. Containers like div and section only pass their contents through. Images linked by address are not downloaded, since fetching them would send requests from your browser to servers you may not know about. Only images embedded as PNG or JPG data URLs are placed on the page.

How to use HTML to PDF

  1. Paste into the HTML box, press Open a file for an .html file, or press Try an example to load a sample invoice.
  2. Look at Structure that will go into the PDF to see what will be kept.
  3. Open Page options for page size, orientation, text size and document title, or tick Add page numbers.
  4. Press Create PDF, then download the file. Print with my browser is there for text outside the Western European character set.

A styled fragment with a remote image and a script

Input
<div style="color:red;display:flex"><h2 class="x">Styled heading</h2><p>Body <b>bold</b> text</p></div><img src="https://example.com/x.png" alt="Logo"><script>1</script>
Output
Styled heading
Body bold text
[Image not included: Logo]

That output was read back from the PDF. The red colour and the flex layout are gone, the heading is a heading, the bold word is bold, the script left no trace, and the missing logo says so instead of vanishing silently.

When it helps

  • Turning an invoice template from a billing script into a file you can send
  • Saving an HTML report from a test run or monitoring tool as a document to attach to a ticket
  • Converting a pasted fragment from a content system when you have no full page to print

Tips for a better result

  • Use real tags. A heading made from a div with a large font size comes out as ordinary text here, while h2 comes out as a heading. Tables need table elements, and CSS grid rows will collapse into paragraphs.
  • Mark header cells with th or put them in thead. Those rows get a shaded background and repeat at the top of each new page if the table runs long.
  • To include a logo, embed it as a base64 data URL in PNG or JPG form. An image embedded that way goes in at 96 pixels per inch, scaled down if it is wider than the column.
  • If you only need the words and no layout at all, HTML to Text is quicker.

Good to know

  • CSS has no effect: no colours, custom fonts, backgrounds, columns, positioning or page-break rules. Print with my browser uses the same cleaned markup with a small fixed stylesheet, so it does not apply your CSS either.
  • No JavaScript runs, so content a page builds with script will be missing. Paste the finished markup, not the source template.
  • Remote images, external stylesheets and web fonts are never loaded, in the preview or in either output. SVG and form elements are removed.
  • Create PDF prints only Western European characters. Other scripts become question marks, and a notice warns you first.

Questions people ask

Why does my PDF not look like my web page?

Because the tool reads the structure of the markup and sets it in its own fixed style. It has no CSS engine. Your browser does have one, so open the page there, choose Print, and pick Save as PDF to keep the design.

Is it safe to paste HTML I did not write?

Scripts and event handlers are stripped before the preview is drawn or the PDF is made. Remote images are swapped for a note before the preview is drawn, so a tracking pixel in a pasted email does not fire, and a link only opens if you click it.

Can I convert a page by entering its URL?

No. There is no server to fetch it, and browsers do not allow one site to read another for you. Save the page or view its source, then paste the HTML here.

What to use next

Last reviewed . Read our editorial policy.