HTML to PDF — Turn HTML Code into a Ready-to-Send PDF
Paste your markup or open an .html file and save it as a PDF with real, selectable text and working links, or as an exact picture of the layout. The conversion runs on your own device from start to finish.
- 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.
Key points
- Paste markup into the box or open an .html / .htm file. Entering a live website address is not supported.
- Pick A4 (selected by default), Letter or Legal, portrait or landscape, a margin between 0 and 200 pt (72 pt is one inch), and optional "Page X of Y" labels.
<script>blocks and inline handlers likeonclickare stripped out before any rendering takes place.- The default Selectable text output gives real text you can search and copy, with clickable http, https and mailto links, set in the standard PDF fonts (Helvetica, Times or Courier).
- Non-Latin scripts and emoji can turn into "?" in that mode; Exact look keeps them by saving each page as a picture instead.
The markup never leaves this browser tab and is not sent to our servers. How on-device processing works · Privacy Policy.
From markup to a PDF people can open
HTML is handy for laying out documents that look polished, like an invoice template, a newsletter, a café menu or a résumé you coded yourself, yet the people receiving it usually expect a PDF. Paste or upload the markup here and it is turned into PDF pages on your own device, with no build pipeline or headless browser to install.
Step by step, under the hood
The first thing that happens is a clean-up: every <script> element and inline event attribute (onclick, onload and the like) is deleted, so no code in the markup can execute. On Convert to PDF, your own browser lays the cleaned HTML out in a hidden, sandboxed frame exactly as wide as the page minus its margins (1 pt equals 1.333 CSS px, so 16 px text prints at 12 pt). Because the browser does the layout, flexbox, grid, tables and floats stay where they should.
With Selectable text, the tool then notes where each word ended up and writes it into the PDF through pdf-lib as genuine text, in the nearest standard PDF font (sans-serif becomes Helvetica, serif becomes Times, monospace becomes Courier, keeping bold and italic), at the same size and colour. Background colours, borders, underlines, bullets, <hr> lines and images are drawn in place, and <a href> links to http, https and mailto addresses become clickable. Page breaks never slice a line of text in half; page-break-before/after: always (or break-before: page) forces a new page, and table rows, images and break-inside: avoid blocks shorter than a page are kept in one piece.
With Exact look, html2canvas photographs the same layout at twice screen resolution and every page becomes an image. It stays truer to web fonts and unusual CSS, but the text cannot be searched or copied and links do not work.
Tick Add page numbers and a small grey "Page 1 of 3" style label goes at the bottom centre of every page. The download is named output.pdf. Preview shows the cleaned HTML at the same content width, but always open the saved PDF to be sure.
Content that comes out well
- Headings, body text, bullet and numbered lists, tables, borders, rounded corners and background colours.
- Layouts built with flexbox, grid or floats, since the browser positions everything before the PDF is written.
- CSS inside a
<style>block or written inline withstyle="". - Pictures embedded as data URLs (
src="data:image/png;base64,…"). - Self-contained, document-like pages that run to one or two pages.
Content that causes trouble
- Pictures hosted elsewhere. Browser security tends to block images from other sites, leaving gaps. Relative paths like
images/logo.pngfail too, since only the HTML file is read and not the folder around it. - External stylesheets and web fonts might not load. Keep the CSS inside the page. In Selectable text mode every font is swapped for Helvetica, Times or Courier, so words stay in place but letter shapes change.
- Jawi, Chinese, Tamil and other non-Latin scripts, plus emoji, fall outside the standard PDF fonts and show as "?" in Selectable text mode. Accented Latin letters such as é or ü are fine. Choose Exact look for anything else.
- Fancy CSS effects such as shadows, background images, rotated text and content added with
::beforeor::afterare skipped in Selectable text mode, and gradients become a flat colour. Exact look keeps them. - Anything a script would draw. Since scripts are removed, charts or text generated by JavaScript will not appear.
- Lengthy documents. Lines are never cut in half, but a heading can still land at the foot of a page. Add
style="page-break-before:always"orbreak-inside:avoidwhere you want control.
Who finds it useful
- Small businesses with an HTML quotation or invoice template showing their SSM registration number, items and SST amount, who need a PDF to email to a customer.
- Students and developers seeing how a styled snippet or coursework page sits on an A4 sheet.
- Anyone keeping an HTML e-receipt or booking confirmation as a PDF for their records; first save or view the email's source as an .html file in your mail app.
- Converting an HTML export from a notes app or site builder into a printable handout.
Tips for better pages
- Declare a font in your CSS, for instance
body{font-family:Arial,sans-serif}, otherwise unstyled elements might inherit this site's own styling. - Keep fixed widths narrower than the page. On A4 portrait with 40 pt margins, the usable width is roughly 687 CSS px.
- Switch to landscape for wide tables.
- Shrink a heavy result with Compress PDF, and attach it to other documents using Merge PDF.
HTML to PDF in four steps
- Put in your HTML. Paste the markup into the text area, or tap Upload HTML file to open an .html or .htm file.
- Set up the page. Choose the output (Selectable text or Exact look), then a page size, orientation and margin, and tick Add page numbers if you would like them.
- Preview it. Tap Preview to view the cleaned markup inside a sandboxed frame at the page's content width, and correct anything that looks off.
- Convert and review. Tap Convert to PDF and output.pdf saves on its own. Open it and look through every page before you send it.
Common questions
Can I type in a website address to convert it?
No. Only HTML that you paste or upload is converted. For a live web page, open it in your browser and choose Print, then Save as PDF.
Why have my images disappeared in the PDF?
Browser security normally blocks pictures pulled from other websites, and relative image paths cannot be resolved because only the HTML file itself is read. Embedding images as data URLs is the dependable fix.
Is the text in the PDF selectable, and do links work?
Yes, with the default Selectable text output. You can highlight, copy and search the words, and links to http, https and mailto addresses can be clicked. In Exact look mode each page is a picture, so neither works.
Why does the PDF use a different font?
Selectable text mode uses the standard PDF fonts: sans-serif fonts become Helvetica, serif fonts become Times and monospace fonts become Courier, with bold and italic kept. Every word stays where the browser put it. For a web font's exact appearance, choose Exact look.
Why do some characters turn into question marks?
The standard PDF fonts only cover Western European letters. Jawi, Chinese, Tamil and other non-Latin scripts, emoji and some symbols become "?" in Selectable text mode. Choose Exact look to keep them as they appear.
Will JavaScript inside my HTML be run?
No. Script tags and inline event handlers are stripped before previewing or converting, so only static HTML and CSS get rendered.
What paper sizes are offered?
A4, Letter and Legal, each in portrait or landscape, with margins anywhere from 0 to 200 points (72 points is one inch, about 25 mm). A4 is selected by default, as it is the normal paper size in Malaysia.
Can page numbers be added?
Yes. Tick Add page numbers before you convert, and a small "Page 1 of 3" style label appears at the bottom centre of every page.
Is my HTML sent to a server?
No. Cleaning, rendering and converting all happen in your browser, and the HTML never reaches our servers. It is free, with no account and no watermark.