HTML to PDF

Generate PDF via browser.

Loading tool…

Turning a web page into a document

HTML describes content that reflows to fit any viewport. PDF describes fixed pages of a defined size. Converting one to the other means pagination: deciding where content breaks across page boundaries, how margins and headers are applied, and what happens to elements that do not fit.

CSS has a whole vocabulary for this. The @page rule sets page size and margins, page-break-inside: avoid keeps a table or figure from being split across pages, and print media queries let you hide navigation and buttons that make no sense on paper. Ignoring all of that is why naive conversions produce documents with headings stranded at the bottom of a page and tables cut in half.

Why we built this tool

The common jobs are generating an invoice or a report from a template, saving a formatted document for signing or archiving, and producing something printable from content that lives as HTML.

Invoices and reports contain customer names, addresses, amounts, and account details. Server-side conversion services receive all of it, and many free ones stamp a watermark on the output as payment. Ours renders the page in your browser and writes the PDF locally, so the document is generated on your machine, nothing is transmitted, and the output carries no branding but yours. There is also no page limit and no queue.

Tips and common mistakes

  • Add print CSS to hide navigation, buttons, and anything else meaningless on paper.
  • Use page-break-inside: avoid to stop tables and figures being split across pages.
  • Set explicit page size and margins rather than relying on defaults.
  • Check the last page — content that overflows by a line is the most common formatting fault.

Open HTML to PDF with a link

HTML to PDF can be handed its input by the link that opens it, so the page arrives with the work already done. This is meant for assistants and scripts: if a chatbot, an editor extension, or a command-line agent already holds your content, it can build a link instead of asking you to copy and paste into a box.

The payload rides in the fragment — the part of a URL after the #. Browsers never send the fragment to a server, so anything handed over this way stays on your device exactly as a dropped file would. A link that uses the query string instead is rewritten into the fragment by the page before any analytics or ad script can read the address.

Prefix any field with gz#gztext= — to pass it as gzip-compressed base64url, which fits roughly five to ten times more into the same link. Links stay reliable up to about 8,000 characters; past that, chat apps and address bars start truncating them, and the page says so rather than loading half a document.

One exception to the privacy rule: ?url= tells the page to download the input from an address. That request goes from your browser straight to that server — not through ours — but it does leave your device, and it only works if the server allows cross-origin requests.

  • #text= — the text to work on
  • #html= — the HTML

Example: https://mygadgets.ink/tools/html-to-pdf/#text=...&html=...

Quick start: using HTML to PDF

  1. Paste your HTML into the input above, including any styles it depends on.
  2. Set the page size and orientation — A4 portrait for most documents.
  3. Generate the PDF and review the page breaks carefully.
  4. Adjust the markup or add print CSS rules if content is splitting badly.
  5. Download the finished document.

Write the source in Markdown and convert it first with Markdown to HTML, then shrink the result with Compress PDF.

Related Document Tools

Browse all Document Tools →