Free tool · HTML and CSS to PDF

HTML to PDF

Paste HTML, add CSS if you like, and download it as a PDF. The HTML is printed by a real browser, so your CSS, web fonts, @media print rules and page breaks work as in Chrome. No sign-up.

Add CSS (optional)

Rendered in a real browser (Chromium). Up to 1 MB of HTML; renders that need more than about 12 seconds are stopped. Images, fonts and styles must use absolute https:// URLs.

HTML to PDF in three steps

  1. Paste the HTML (a whole document or a fragment) or open an .html file from your computer. Put extra CSS in the CSS field if you want to keep it apart.
  2. Choose the layout: paper size (A4, Letter, Legal or A3), portrait or landscape, margins, and whether the print or screen CSS rules apply.
  3. Create the PDF, check the preview and download it.

What works in the HTML

FeatureWorks?
CSS, flexbox and grid, @media printYes, as in Chrome
Web fonts (@font-face, Google Fonts)Yes, from absolute https:// URLs
Images, SVG, background imagesYes, inline or from absolute https:// URLs
JavaScript (charts, templating)Yes; it has to finish within the render time
Page breaks (break-before, break-inside: avoid)Yes
Relative URLs (/css/style.css, img/logo.png)No: the HTML has no address. Use absolute URLs or a <base href>
http:// resourcesUpgraded to https or blocked, as on any https page

Several pages or one long page

A normal PDF splits the document into sheets of the chosen paper size. With Whole document on one long PDF page, you get everything on a single page as wide as the paper and as tall as the content (up to 200 inches): good for receipts and long reports you want to keep in one piece.

Limits

LimitValue
HTML size1 MB in this tool, 5 MB with the API
Time per PDFabout 12 seconds to render and print; slower documents are stopped
Pagesat most 30

Convert HTML to PDF from your code

The HTML to PDF API does the same in one request: POST the HTML in a JSON body to /v1/take with format=pdf and get the PDF back. It adds what the tool leaves out: custom margins per side, scaling, page ranges, a wait for late content and a file name for the download. See the Render HTML documentation. To print a web page by its address instead, use URL to PDF.

Frequently asked questions

How do I convert HTML to PDF?

Paste the HTML into the field or open an .html file, choose the paper size, orientation and margins, and click Create PDF. The HTML is printed by Chromium on our servers, and after a few seconds you can preview the PDF and download it.

Do CSS and web fonts work?

Yes. The HTML is rendered by Chromium, so CSS, @font-face web fonts, @page rules, page-break properties and JavaScript work as in Chrome. Stylesheets, fonts and images must be loaded from absolute https:// URLs: relative paths do not resolve, because the HTML has no address of its own.

Is my HTML stored?

No. The HTML is sent to the renderer, the PDF is sent straight back to your browser, and neither is stored or logged. The PDF stays only in this tab, so download it before you close the page.

Why does the PDF hide some parts of my page?

By default the HTML is printed with its @media print rules, like Save as PDF in a browser. Choose CSS media: screen to print it as it looks in a browser window.

How large can the HTML be?

Up to 1 MB in this free tool, and up to 5 MB with the API. Rendering, including fonts and images, has to finish within about 12 seconds.

How many PDFs can I create for free?

The free tools allow 5 requests an hour and 30 a day per visitor, shared with our other free tools. For more, use the API: the free plan includes 300 requests a month, and each PDF counts as one.

HTML to PDF API

Create PDFs from your HTML templates

POST /v1/take with html and format=pdf prints the HTML your application generates, such as invoices, reports or certificates, and returns the PDF: paper size, orientation, margins, print or screen styles, page ranges, or the whole document on one long page.

/v1/take documentation HTML to PDF API All documentation

300 free requests every month, and each PDF counts as one. HTML up to 5 MB. No credit card required.

POST https://api.screenshotbase.com/v1/take

# Response: the PDF (application/pdf)
curl -X POST "https://api.screenshotbase.com/v1/take" \
  -H "apikey: YOUR-API-KEY" \
  -H "Content-Type: application/json" \
  -d '{"html": "<h1>Invoice INV-42</h1>", "format": "pdf", "pdf_margin": "15mm"}' \
  -o invoice.pdf

More free tools

Start using our Screenshot API for free today!

Get 300 requests / month for free