Short answer: To convert HTML to PDF free online, paste your HTML code into the code box or enter the URL of a public webpage, adjust paper size, orientation, and margins in the live preview, then save through your browser’s print dialog. Pasted code is rendered locally — nothing is uploaded, no signup, no cost.
Need a PDF from a web page or a snippet of code? This free html to pdf converter gives you two ways in: paste raw HTML with your <style> block, or enter the URL of any public page. You get a live preview with paper size, orientation, and margin controls — then save the PDF through your browser’s print dialog.
Pasted code never leaves your device; it is rendered locally in a sandboxed preview. URL mode fetches public pages through a free relay service, which is disclosed right in the tool. No signup, no software, no watermarks — just a clean PDF made the way browsers were designed to make them.
How to convert HTML code or a webpage URL to PDF
Paste mode: drop your code — a full document or a snippet — into the code box. Your style block is honored, so what you styled is what you get, and the preview updates as you type. Choose paper size (A4, US Letter, Legal, A3, A5), portrait or landscape, and margins, then click Print / Save as PDF and pick Save as PDF as the destination in your browser’s print dialog. Hit Load sample any time to see a styled invoice convert end to end.
URL mode: switch tabs, enter the address of a public page, and click Fetch page. The page is retrieved through a free public relay and shown in the preview for you to review before printing to PDF. This is the fastest route to archiving an article, saving a receipt page, or keeping an offline copy of documentation.
Getting a clean PDF from the print dialog
The final save uses your browser’s print dialog, which is more powerful than most people realize. Choose Save as PDF as the destination, turn background graphics on if your design uses background colors or shaded table headers (browsers drop backgrounds by default), and turn headers and footers off for a clean document without the URL and date stamped on every page.
The paper size, orientation, and margins you picked in the tool are applied automatically via print CSS — for the details of what browsers support, see MDN’s reference on the @page rule. You can also control print behavior from your own code with @page rules and page-break properties, because the preview is a real browser render, not a screenshot.
Honest limits: logins, JavaScript, and long pages
Pages behind a login cannot be fetched by the relay, so URL mode is public-pages only. Pages that need JavaScript to render — single-page apps, infinite-scroll feeds — may convert incompletely in the sandboxed preview; for those, open the page in your own browser and use its Print to Save as PDF directly. Very long pages become very long PDFs — narrow the margins or switch to landscape for wide tables.
For privacy: paste mode is the safest HTML-to-PDF workflow that exists, because your code never leaves your device. URL mode necessarily sends the page address to the relay service, so use it only for public pages.
From HTML to PDF to finished document
Developers turn generated HTML reports into PDFs for clients without adding a server-side library; freelancers paste invoice markup and save polished PDFs the same day; students archive tutorials before links rot. Once converted, you can stamp the result with our Watermark PDF tool or lock it down with Protect PDF before sharing.
HTML to PDF
Turn pasted HTML code or any public web page into a PDF. Preview it live, then save with your browser's print dialog.
Public pages only. The page is fetched through a free public relay service (api.allorigins.win) so your browser can read it — pages behind a login, or ones that need JavaScript to render, may not convert fully.
🔒 100% private — your files never leave your device. Pasted HTML is rendered locally in your browser; URL mode fetches the public page through a free relay service, as explained above.
Key takeaways
- Html to pdf in two ways: paste your own HTML code, or fetch any public webpage by URL — then save through your browser’s print dialog.
- Paste mode renders locally on your device, so it is safe for invoices, contracts, and other sensitive documents.
- URL mode is public pages only — login-walled or heavily JavaScript-driven pages may convert incompletely.
- Print dialog tips: choose Save as PDF as the destination, toggle background graphics on when your design needs colors, and turn headers and footers off for a clean document.
- Real conversion keeps text selectable and searchable with proper pagination — far better than screenshots.
How to convert HTML to PDF
Paste-HTML mode: paste your code — a full HTML document or just a snippet — into the code box. Your <style> block is honored, so what you styled is what you get. The live preview updates as you type. Choose paper size (A4, US Letter, Legal, A3, A5), portrait or landscape, and margins, then click Print / Save as PDF and pick Save as PDF as the destination in your browser’s print dialog. Hit Load sample any time to see a styled invoice convert end to end.
URL mode: switch tabs, enter the address of a public page, and click Fetch page. The page is retrieved through a free public relay and shown in the preview. Review it, adjust paper settings, then print to PDF the same way. This is the fastest route to archiving an article, saving a receipt page, or keeping an offline copy of documentation.
Paste HTML or page URL: which mode fits your job?
Use paste mode when you control the markup: invoices and receipts generated by your app, email templates you want to proof as PDFs, reports assembled from code, or HTML exports from other tools. Because the code never leaves your device, it is also the right choice for anything sensitive — draft contracts, internal memos, anything you would not paste into a stranger’s website.
Use URL mode when the content already lives on the web: a tutorial you want to read offline, a product page for your records, a confirmation screen, documentation you reference often. It only works for public pages — anything behind a login is out of reach, since the relay fetches the page without your session.
The two modes share the same print pipeline, so paper size, orientation, and margins behave identically whichever you pick.
Getting a clean PDF from the print dialog
The final save uses your browser’s print dialog, which is more powerful than most people realize. A few settings make the difference between a messy printout and a professional PDF:
Destination: choose Save as PDF (Chrome, Edge) or Microsoft Print to PDF / Save as PDF (Firefox, Safari). Background graphics: turn this on if your design uses background colors or shaded table headers — browsers drop backgrounds by default. Headers and footers: turn these off for a clean document without the URL and date stamped on every page. The paper size, orientation, and margins you picked in the tool are applied automatically via print CSS, but you can still fine-tune them in the dialog.
For pasted HTML, you can also control print behavior from your own code: @page rules, page-break-before, and print-specific styles all work because the preview is a real browser render — not a screenshot.
Honest limitations of browser-based HTML to PDF
This tool renders with your browser, which means the PDF matches what the browser can display — usually excellent for articles, invoices, and styled documents. There are edges worth knowing:
Pages that need JavaScript to render (single-page apps, infinite-scroll feeds) may convert incompletely in URL mode, because the sandboxed preview does not run page scripts. For those, open the page in your browser and use its own Print → Save as PDF directly. Login-walled pages cannot be fetched by the relay. And very long pages become very long PDFs — consider narrowing margins or switching to landscape for wide tables.
On the privacy side, paste mode is the safest HTML-to-PDF workflow that exists: your code is rendered locally and nothing is transmitted. URL mode necessarily sends the page address to the relay service, which is why it is limited to public content and disclosed in the tool itself.
Everyday uses for an HTML to PDF converter
Developers turn generated HTML reports into PDFs for clients without adding a server-side library. Freelancers paste invoice markup and save polished PDFs to send the same day. Students archive tutorials and documentation before links rot. Shoppers save order confirmations and warranty pages as permanent records. Bloggers convert draft posts to PDF for offline editing or sharing with an editor who prefers documents over links.
Compared with screenshot tools, a real HTML-to-PDF conversion keeps text selectable and searchable, keeps file sizes small, and paginates properly instead of producing one giant image. That is why, for anything text-based, converting beats screenshotting every time.
HTML to PDF: frequently asked questions
How do I convert pasted HTML code to PDF?
Paste your HTML — a full document or a snippet — into the code box on the Paste HTML tab. Your style block is honored and the preview updates live as you type. Set paper size, orientation, and margins, then click Print / Save as PDF and choose Save as PDF as the destination in your browser’s print dialog. Your code never leaves your device during the whole process.
How do I save a webpage as a PDF?
Switch to the From page URL tab, enter the address of a public page, and click Fetch page. The page is retrieved through a free public relay and shown in a live preview where you can adjust paper settings before printing to PDF. Pages behind a login cannot be fetched, and pages that need JavaScript to render may convert incompletely.
Will my CSS styles and formatting survive the conversion?
Yes. The preview renders your markup with a real browser engine, so CSS layouts, colors, tables, and fonts appear as designed. Include a meta charset tag for best results, and enable background graphics in the print dialog if your design relies on background colors or shaded elements.
Can I convert a website that requires a login?
No. URL mode fetches pages through a public relay without your login session, so anything behind a password is out of reach. For login-walled pages, open the page in your own browser while logged in and use its Print → Save as PDF command directly — or save the page’s HTML and convert it in paste mode.
Is it private to convert HTML to PDF with this free tool?
Paste mode is private because your code never leaves your device — it is rendered locally in a sandboxed preview with no upload step at all. That makes it suitable for invoices, draft contracts, and internal documents. URL mode is different: the page address goes through a public relay service, so use it only for public pages, as the tool itself explains.
Related free tools
- Image to PDF Converter — build PDFs from scanned images.
- Watermark PDF — stamp the converted PDF.
- Rotate PDF — fix any sideways pages before sharing.
- Protect PDF — lock the result with a password.
From invoice markup to a saved tutorial, this html to pdf converter handles both paste and URL modes for free. For fine control over printed pages — page sizes, margins, and page breaks — MDN’s @page reference documents exactly what browsers support; paste the result above and save your PDF in seconds.