HTML to PDF — Turn HTML Code into a Shareable PDF
Paste your markup or open a saved .html file, choose the paper size, and get a PDF back. The HTML is rendered and converted on your own device.
- Free
- No sign-up
- No watermark
- Runs in your browser
Selectable text keeps real text and working links, using standard PDF fonts. Exact look captures each page as a picture: use it for non-Latin scripts, emoji, web fonts or very complex designs.
Quick facts
- Paste markup into the editor or open an .html / .htm file. Entering a URL to fetch a live site is not supported.
- Paper: Letter (selected at first), Legal or A4, portrait or landscape, with 0–200 pt margins (72 pt = 1 inch) and optional “Page 1 of 3” labels.
- Before rendering,
<script>tags and inline handlers likeonclickare stripped. - By default the PDF has real, selectable text and clickable http, https and mailto links. Fonts become the standard PDF fonts (Helvetica, Times or Courier).
- Non-Latin text and emoji can show as “?” in text mode. Switch to Exact look (image) for those, at the cost of selectable text.
The code you paste never leaves this tab and is not sent to our servers. See What on-device processing means and our Privacy Policy.
Make a PDF from HTML without installing anything
HTML is a handy way to lay out a polished document: an invoice template, a newsletter, a printable flyer, a résumé you coded yourself. The people receiving it, though, usually expect a PDF. This converter takes the markup you supply and produces PDF pages right on your computer, with no command-line tools or headless browser to configure.
What happens when you convert
The first thing the tool does is remove every <script> element and inline event attribute (onclick, onload and the like), so none of the code can run. On Convert to PDF, your own browser lays out the cleaned HTML in a hidden, sandboxed frame exactly as wide as your page minus its margins (1 pt = 1.333 CSS px, so 16 px text becomes 12 pt). Because the browser does the layout, flexbox, grid, tables and floats keep their positions.
In Selectable text mode (the default), the tool measures where every word landed and writes it into the PDF as real text, in the closest standard PDF font (sans-serif becomes Helvetica, serif becomes Times, monospace becomes Courier, with bold and italic kept), at the same size and color. Background colors, borders, underlines, list bullets, <hr> lines and images are drawn in place, and links to http, https and mailto addresses become clickable. Pages are split so a line of text is never cut in half; page-break-before/after: always (or break-before: page) starts a new page, and table rows, images and break-inside: avoid blocks shorter than a page are kept together.
In Exact look mode, html2canvas captures the same layout as a picture at twice screen resolution and each page is an image. It looks closer to the browser for web fonts and unusual CSS, but the text cannot be selected or searched and links do not work.
With Add page numbers ticked, a small gray “Page 1 of 3” label appears centered at the bottom of every page. The finished file downloads as output.pdf. Preview shows the cleaned HTML at the same content width, but always open the download to confirm.
Content that converts cleanly
- Headings, body text, bulleted and numbered lists, tables, borders, rounded corners and background colors.
- Layouts built with flexbox, grid or floats, because the browser positions everything first.
- Styling placed in a
<style>block, or inline throughstyle=""attributes. - Images written straight into the markup as data URLs (
src="data:image/png;base64,…"). - Self-contained, document-like pages that run to a page or two.
Content that causes trouble
- Images hosted elsewhere. Browser security usually blocks them, leaving blank boxes. Relative paths like
images/logo.pngalso fail, since only the HTML file is read and not the folder around it. - External stylesheets and web fonts may not load at all. Put the CSS directly in the page. In Selectable text mode every font becomes Helvetica, Times or Courier, so word positions are kept but letter shapes change.
- Non-Latin scripts and emoji (Chinese, Arabic, Hindi and so on) are outside the standard PDF fonts and show as “?” in Selectable text mode. Accented letters such as é, ü and ñ are fine. Use Exact look for other scripts.
- Advanced CSS effects such as shadows, background images, rotated text and text added with
::before/::afterare skipped in Selectable text mode, and gradients become a flat color. Use Exact look if they matter. - Content generated by scripts. Because scripts are removed, charts or text that code would have generated will not appear.
- Lengthy documents. Lines are never cut in half, but a heading can still land at the bottom of a page. Add
style="page-break-before:always"orbreak-inside:avoidwhere you want control.
Ways people use it
- Freelancers and small shops with an HTML invoice or estimate template (business name, EIN, line items, sales tax) that needs to go to a client as a PDF.
- Web development students checking how a styled page or assignment prints on Letter or A4.
- Keeping an HTML order confirmation or e-receipt on file for expense reports. Save the message source as .html from your email client first.
- Converting an HTML export from a note-taking app or site builder into a handout for a meeting or class.
Tips for a cleaner result
- Declare a font in your CSS, such as
body{font-family:Arial,sans-serif}. Elements without styling can otherwise inherit this site's default look. - Keep fixed widths narrower than the page. On Letter portrait with 40 pt margins, the usable width is about 709 CSS px; on A4 it is about 687 px.
- Wide tables fit better once you change the orientation to landscape.
- Shrink a bulky result with Compress PDF, or attach it to other files with Merge PDF.
Convert HTML to PDF in four steps
- Bring in the HTML. Paste markup into the editor box, or press Upload HTML file and choose an .html or .htm file.
- Set up the page. Pick the output (Selectable text or Exact look), paper size, orientation and margin, and tick Add page numbers if you need them.
- Check the preview. Press Preview to view the cleaned markup in a sandboxed frame at your page’s content width and correct anything that looks off.
- Create and review. Press Convert to PDF. The file saves as output.pdf; open it and look through every page before you send it.
HTML to PDF questions
Can I type in a website address to convert a live page?
No. The tool only works with HTML you paste or open from a file. To keep a copy of a live web page, open it in your browser, choose Print and pick Save as PDF.
Why do my images show up blank in the PDF?
Browsers usually block pictures pulled from other websites, and relative image paths have nothing to point to because only the HTML file itself is loaded. Putting the images into the HTML as data URLs gets around both problems.
Will the text in the PDF be selectable, and will links work?
Yes, in the default Selectable text mode. Text can be selected, copied and searched, and links to http, https and mailto addresses are clickable. In Exact look mode each page is an image, so neither works.
Why does my PDF use a different font?
Selectable text mode writes text with the standard PDF fonts: sans-serif fonts become Helvetica, serif fonts become Times and monospace fonts become Courier, with bold and italic kept. Each word stays where the browser placed it. To keep a web font’s exact look, choose Exact look (image).
Why do some characters show as a question mark?
The standard PDF fonts only cover Western European characters. Non-Latin scripts such as Chinese, Arabic or Hindi, emoji and some symbols become “?” in Selectable text mode. Choose Exact look (image) to keep them as they appear.
Is the JavaScript in my HTML executed?
No. Script elements and inline event handlers are stripped out before the preview or the conversion, so only static HTML and CSS are drawn.
What paper sizes are available?
Letter, Legal and A4, each in portrait or landscape, with margins anywhere from 0 to 200 points (72 points is 1 inch). The menu starts on US Letter.
Is there a way to number the pages?
Yes. Tick Add page numbers before converting and each page gets a small “Page 1 of 3” style label centered at the bottom.
Does my HTML get uploaded during conversion?
No. Cleaning, rendering and converting all happen in your browser, and your code is not sent to our servers. There is no charge, sign-up or watermark.