HTML to PDF Converter — Paste HTML Code or Upload a File

Convert HTML code to PDF free online. Paste your HTML, upload a file or start from a template, check the live page preview, and download a PDF with selectable text and clickable links. 100% in your browser — your HTML is never uploaded.

Drop an HTML file here or click to browse

.html, .htm or .txt files, up to 10 MB

or
  • Never uploaded — converting happens in your browser
  • No sign-up, no watermark, hTML files up to 10 MB

HTML to PDF conversion turns HTML code into a fixed-layout PDF file. This converter accepts HTML typed or pasted into a built-in editor, .html or .htm files from your device, or .txt files that contain HTML. The live preview lays your HTML out on the page size you choose, with a dashed line wherever a new page starts, and the PDF uses the same layout. Sizes are true to paper: 12pt text prints at 12pt. Lines of text, pictures and table rows are kept whole at page breaks, the text in the PDF can be selected, searched and copied, and links stay clickable. Styles in a <style> block or style attributes are applied, including print styles, and so are style sheets, web fonts and pictures linked from other websites — your browser loads them straight from those websites, and the converter tells you if any couldn't be included. Everything runs in your browser — your HTML never leaves your device.

How it works

How to Convert HTML to PDF

Three steps. Three input methods. Browser-based — no server round-trip.

  1. Step 1: Add Your HTML Content

    Choose one of three ways to add your HTML. Drop an .html, .htm, or .txt file onto the upload area; click Paste HTML Code and type or paste your code into the editor (useful for code snippets, generated HTML, or content copied from a CMS); or click Start with Template to begin with a sample document and replace it with your own.

  2. Step 2: Use the Live Preview and Set Page Size

    The live preview updates as you edit and shows your HTML on the page size you choose, with a dashed line wherever a new page starts. Check how tables and text fall across pages. Choose the page size — A4 is the default, with US Letter, US Legal and A3 — portrait or landscape, and the margin.

  3. Step 3: Download Your PDF

    Click Convert to PDF. The PDF is laid out the same way as the preview and saved to your device, with text you can select and search and links you can click. No watermark is added. No account is required. Your HTML code and any file content remain in your browser throughout — nothing is transmitted to a server at any point in the process.

Developer features

What This HTML to PDF Converter Includes

Live preview of the real pages

The preview is laid out by the same routine that makes the PDF: the same page width, the same styles, and a dashed line wherever a new page starts. Change the page size, orientation or margin and it re-flows, so you see how tables and text fall across pages before you download.

Paste HTML code

A built-in editor lets you type or paste HTML code without uploading a file. Useful for snippets, generated templates, or code copied from a CMS or design tool. Fragments get clean default styling; a complete document keeps only its own styles.

Selectable text, clickable links

Each PDF page carries its words as real text, so the PDF can be searched, selected and copied, whatever alphabet it is written in. Web and email links stay clickable, and so do links to a place in the same document.

Clean page breaks

Pages end between lines, never through them: text, pictures and table rows stay whole. CSS page-break rules (break-before, break-after, break-inside) and print styles are followed, and content wider than the page is shrunk to fit.

Files stay in browser

Processing runs in your browser using JavaScript. Your HTML code and any file you open are never sent to a server, which matters for proprietary templates and documents with customer data.

Starter template

Click Start with Template to load a sample document with headings, a list, a table and a code block, then replace it with your own content. Or click Paste HTML Code to start from an empty editor.

Developer note — external resources

Style sheets, web fonts and pictures linked from other websites over https are loaded by your browser straight from those websites. A picture or font can be copied into the PDF only when its website lets other sites use it — most CDNs and Google Fonts do — and the preview and the finished PDF name anything that couldn't be included. Scripts, frames and videos from other websites are not loaded, and files referred to by a path such as style.css can't be found. To include those:

  • • Inline CSS rules into a <style> block in the HTML <head> section, or apply them as style= attributes on individual elements
  • • Embed images and fonts as base64 data URIs — files on your computer, or on a website that doesn't let other sites use them
  • • A few CSS effects are not drawn: filters, blend modes, clip-path, conic gradients and text clipped to a background

What This HTML to PDF Converter Is Used For

  • Developer document generation. Developers generating invoices, reports, or certificates programmatically in HTML often need a quick way to test how the output renders as a PDF without setting up a server-side PDF library. The live preview editor lets you paste generated HTML directly and see the PDF layout instantly. Browser-based processing means the test HTML — which may contain real customer data from a development environment — never leaves your device.
  • Email template to PDF conversion. Marketing teams and developers who build HTML email templates often need a PDF version for print, archiving, or client approval. Pasting the email HTML into the editor and downloading the PDF is faster than setting up a headless browser or server-side rendering pipeline. Inline CSS support ensures email-style formatting is preserved.
  • Content and document creation from HTML. Technical writers, content teams, and educators working with HTML content — course notes, guides, technical documentation, reference materials — can paste their HTML into the editor and produce a formatted PDF document. The template option provides a pre-structured starting point for users who don't write HTML from scratch.
  • Sensitive or proprietary HTML. Legal teams, product teams, and agencies working with HTML containing unreleased designs, confidential business documents, or client-specific templates cannot use server-based tools that retain uploaded files. Browser-based conversion is the only option for this use case without deploying local software.
  • Quick prototyping and layout testing. Designers and developers testing how an HTML layout renders at different page sizes can use the live preview to iterate without downloading and reviewing repeated outputs. Change the HTML, see the preview update, adjust the page-size setting, and download when the layout is correct.

How we compare

Private, instant, live preview

Type or paste HTML, see the preview live, and download a properly formatted PDF — all without leaving your browser.

FeatureOurshtml2pdf.wsCloudConvertSejdaweb2pdfconvert
Free & unlimited25/day3/hr15/day
No account needed
Files stay in browser
Live preview
Custom HTML editor
Starter template
Page size options
Inline CSS support

Competitor information was accurate at time of publication and may have changed.

Need a screenshot first?

Need a picture of a live website instead? ScreenSnap takes a full page screenshot in Chrome and saves it as PNG, JPG or PDF — free, and your screenshots never leave your browser.

Get ScreenSnap — free

Frequently Asked Questions

How do I convert HTML to PDF for free?
Go to oneclickpdf.net/tools/html-to-pdf and either paste your HTML code into the editor, drop an HTML file onto the upload area, or start from the template. The live preview shows the pages as they will be in the PDF. Choose the page size, orientation and margin, then click Convert to PDF. The conversion runs entirely in your browser — your HTML never leaves your device. No account or signup is required, and no watermark is added.
How do I convert HTML code to PDF without saving it as a file?
Click Paste HTML Code, paste your code into the editor and click Convert to PDF — there is nothing to save or upload first. A fragment (a few tags without html or body) is given clean default styling: a readable font, spacing and table borders. A complete document that starts with a doctype or an html tag keeps only its own styles. CSS in a style block or in style attributes is applied, and the live preview updates as you type.
Does the live preview show exactly what the PDF will look like?
The preview is laid out by the same routine that makes the PDF, at the same page width and with the same styles, and a dashed line marks where each new page starts. Change the page size, orientation or margin and the preview re-flows. Two things differ: scripts in your HTML run when you convert but not in the preview, and a page that sizes itself to the window height (100vh) is shown approximately.
Is the text in the PDF selectable and searchable?
Yes. Each page of the PDF is a high-resolution picture of your rendered HTML with the page's words laid over it as invisible text, so you can select, copy and search the text in any PDF reader, whatever alphabet it is written in (emoji and a few very rare characters are left out of the text). Web and email links stay clickable, and so do links to a place in the same document; a link with a relative address has nowhere to point and gets none. Because the visible page is a picture, it is not vector: zooming far in shows pixels. Documents of up to 15 pages are drawn at 192 dpi, longer ones at 144 dpi, and those over 100 pages at 120 dpi.
What HTML and CSS features are supported?
Standard HTML — headings, paragraphs, tables, lists, images, links, forms, inline SVG and canvas — and the CSS your browser lays out, including Flexbox and Grid. Styles in a style block and in style attributes are applied, and so are print styles (@media print). A few effects are not drawn: filters, blend modes, clip-path, conic gradients and text clipped to a background. Style sheets linked from other websites, such as Bootstrap from a CDN, and web fonts such as Google Fonts are loaded too.
How do I control where the pages break?
Pages break between lines of text, pictures and table rows, never through them, and a heading stays with the text that follows it. To start a new page at a chosen point, give that element the CSS break-before: page (or page-break-before: always), or use the page break button in the editor toolbar. To keep a block on one page, give it break-inside: avoid. A document can be up to 250 pages.
Will my HTML code be uploaded to a server during conversion?
No. The converter runs inside your browser using JavaScript. Your HTML code and any file content are processed locally on your device and never transmitted to a server. html2pdf.ws, CloudConvert, Sejda, and web2pdfconvert all send your HTML or URL to their servers for processing. If your HTML contains confidential content — proprietary templates, sensitive client data, or internal document structure — browser-based conversion ensures that content does not leave your machine at any point during conversion. If your HTML links pictures, style sheets or fonts on other websites, your browser fetches those from that website, as it does when you open the page; your HTML itself is not sent.
What page size options are available for HTML to PDF conversion?
A4, US Letter, US Legal and A3, each in portrait or landscape, with a margin from 0 to 144 points (2 inches). Sizes are true to paper: one CSS inch is one inch on the page, so 12pt text prints at 12pt and a 100mm box measures 100 mm. Content wider than the page is shrunk to fit, down to half size — choose Landscape or a larger page for wide tables.
Can I use an HTML template to get started?
Yes. Click Start with Template to open the editor with a sample document — headings, a list, a table and a code block — and replace it with your own content. You can also click Paste HTML Code to start from an empty editor if you prefer to write or paste your own HTML.
What file formats can I upload to the HTML to PDF converter?
The converter accepts .html, .htm, and .txt files of up to 10 MB, and HTML pasted directly into the built-in editor. A file saved in an older encoding such as Windows-1252 is read correctly when it declares its encoding. Plain text files without HTML structure render as plain text. A file that isn't text — a PDF, a picture, a Word document — is turned away with a message, and web archives (.mht) aren't supported: save the page as “Web Page, HTML Only” instead. No account is required for any of these input methods.
Can I convert an HTML document that uses external stylesheets?
Yes. Style sheets, web fonts such as Google Fonts and pictures linked from other websites over https are loaded by your browser straight from those websites — your HTML is not uploaded — and appear in the PDF, print styles included. A picture or font can be copied into the PDF only if its website lets other sites use it (most CDNs, Google Fonts and Wikimedia do); when one doesn't, the preview or the finished PDF says so, and you can embed it in the HTML as a base64 data URI instead. Files referred to by a path such as style.css or images/logo.png can't be found: paste the CSS into a style block and embed pictures as data URIs. Scripts, frames and videos from other websites are not loaded.
Does JavaScript in my HTML run?
Scripts written inside your HTML run when you click Convert to PDF, so content they build — a table filled from data, a chart drawn on a canvas — appears in the PDF. They run sealed off from this site and from the internet, and they do not run in the live preview. Scripts loaded from other websites, such as a library on a CDN, are not loaded.
Can I convert a live web page by its address?
This tool converts HTML code. To convert a page by its URL, use the Webpage to PDF tool at oneclickpdf.net/tools/webpage-to-pdf, which fetches the page for you.
Can I convert HTML to PDF on a phone or tablet?
Yes. The converter works in any modern mobile browser, including Safari on iPhone and iPad and Chrome on Android. Open the page in your mobile browser, tap the upload area to select an HTML file, or use the built-in editor to paste HTML directly; on a phone the code and the preview are on separate tabs. The conversion runs in your browser without any app installation required. The PDF is available to download immediately and opens in any mobile PDF viewer or sharing application on your device.