Convert HTML to PDF in Your Browser

To convert HTML to PDF, paste your HTML code or upload an .html file below, choose a paper size such as A4 or Letter, and click Convert to PDF. ScreenshotAPI.net renders the markup in a real browser with your CSS and JavaScript applied, then gives you a PDF to preview and download for free, with no signup.

Paper size

Free to use. No account required.

Step by step

How to Convert HTML to PDF in 3 Steps

The whole job takes under a minute, and it works the same for a single line of markup or a full HTML file with its own styles.

  1. 1

    Add your HTML

    Paste HTML code into the editor, or switch to the upload tab and drop in an .html or .htm file from your computer.

    custom_html
  2. 2

    Choose the page setup

    Pick A4, Letter, Legal, A3, A5, or Tabloid, turn on landscape for wide tables, and enter a page range if you only need part of the document.

    format · landscape · page_range
  3. 3

    Convert and download

    Click Convert to PDF. The markup is rendered in a real browser, paginated to your paper size, and shown in the preview so you can download it.

    file_type=pdf
Two ways in

Paste HTML Code or Upload an HTML File

Both inputs go through the same renderer, so pick whichever matches where your HTML lives right now.

HTML code to PDF

Best for snippets, email templates, and markup your app generates on the fly. Paste anything from a single tag to a full document with a <head>. Styles in a <style> block or a style attribute are applied, and you see a live preview before you convert.

HTML file to PDF

Best when you already have a saved page, an exported report, or a template on disk. The file is read in your browser and sent as HTML, so it never needs a public URL. Files up to 1 MB work in the free tool. Larger documents go through the API.

One limit applies to both: a single HTML file cannot carry the folders next to it. Images, fonts, and stylesheets that sit beside the file on your disk will not load, so link them with full https:// URLs or inline them.

Page setup

Page Size, Orientation, and Print Styles

The paper size decides how wide your layout is allowed to be. A4 portrait is narrower than most desktop screens, so a page that looks fine in the browser can wrap differently on paper. Here are the sizes side by side, drawn to scale.

A5148 × 210 mmA4210 × 297 mmLetter8.5 × 11 inLegal8.5 × 14 inTabloid11 × 17 inA3297 × 420 mm
Paper size
A0 to A6, Letter, Legal, Tabloid, and Ledger. Leave it out on the API to get one long page with no breaks.
pdf_options[format]
Orientation
Turns the sheet sideways. Use it for wide tables, dashboards, and anything that would otherwise shrink to fit.
pdf_options[landscape]
Page range
Keeps only the pages you ask for, such as 2-6. Handy when a long document only needs its summary page.
pdf_options[page_range]
Print styles
Applies your @media print rules, so you can hide navigation or buttons that do not belong on paper.
pdf_options[media]=print
Backgrounds
Keeps background colours and images. Print mode drops them by default to save ink.
pdf_options[print_background]

The free converter covers paper size, landscape, and page range. Print media and backgrounds are available on the API.

Rendering

Why Your CSS and Images Look Right in the PDF

A PDF is only as good as the engine that lays out the HTML. ScreenshotAPI.net renders it in a browser first, which is why the PDF matches the preview. Four things are worth knowing.

CSSYour styles are applied, not stripped
The HTML is loaded in a real browser engine, so a <style> block, inline style attributes, flexbox, grid, and web fonts from a stylesheet link all render the way they do on screen.
JavaScriptScripts run before the PDF is built
Inline JavaScript executes during rendering, so charts and content you inject with a script make it onto the page. If a chart animates in, add a short delay on the API so it finishes first.
ImagesRelative paths have nothing to point at
This is the most common reason images or fonts go missing. Pasted HTML has no folder or domain behind it, so a path like images/logo.png cannot be found. Use a full URL, or embed small images as data URIs.
Breaks<img src="images/logo.png">
Works<img src="https://example.com/logo.png">
Which tool do you need?

HTML to PDF vs Saving a Webpage as PDF

Both end in a PDF, but they start from different places. If you want to save HTML as PDF and the HTML is in your hands, use this page. If it lives at a web address, use the webpage converter.

You are here

HTML to PDF Converter

You start with
HTML code or an .html file
Content comes from
Exactly the markup you give it
Works for private pages
Yes, nothing has to be online
Typical job
Invoices, receipts, certificates, templates
Convert HTML now

Different input

Webpage to PDF Converter

You start with
A link to a live, public page
Content comes from
Whatever the site serves when it loads
Works for private pages
Only if the page is publicly reachable
Typical job
Articles, docs, receipts from a site, archives
Save a webpage as PDF
Use Cases

What People Build With HTML to PDF

Any document that starts life as a template is a good fit. Write it once in HTML and CSS, then turn every copy into a PDF.

Invoices

Keep one HTML invoice template, fill in the numbers, and turn each one into an A4 or Letter PDF that is ready to email.

Reports

Export a monthly report built with HTML tables and charts as a PDF that clients can file and print without a login.

Certificates

Design a certificate once in HTML and CSS, switch to landscape, and produce a personalised PDF for every attendee.

Tickets and passes

Render event tickets and boarding passes with a QR code image from a URL, sized to fit a single printed page.

Receipts

Turn the HTML receipt your checkout already sends by email into a PDF copy customers can download later.

Contracts and quotes

Generate quotes and agreements from HTML templates on Legal or Letter paper, keeping fonts and spacing consistent.

Do this via the API

Automate HTML to PDF With the ScreenshotAPI.net API

Generating invoices or certificates from your app? Send the same HTML in a POST request and get the PDF back in one call, from cURL, JavaScript, Python, or any language that speaks HTTP.

custom_html
Your HTML as a string. It overrides url, and inline CSS and JavaScript are applied.
pdf_options.format
A0 to A6, Letter, Legal, Tabloid, or Ledger.
pdf_options.landscape
true for wide layouts, false for portrait.
pdf_options.page_range
Keep only some pages, for example 1-3.
POSThttps://shot.screenshotapi.net/v3/screenshot
curl -X POST "https://shot.screenshotapi.net/v3/screenshot" \
  -H "Content-Type: application/json" \
  -d '{
    "token": "YOUR_API_KEY",
    "custom_html": "<h1>Invoice #1042</h1><p>Amount due: $500</p>",
    "file_type": "pdf",
    "output": "image",
    "pdf_options": {
      "format": "A4",
      "landscape": false
    }
  }' \
  --output invoice.pdf
Honest comparison

Free HTML to PDF Converter vs Other Online Tools

The best HTML to PDF converter depends on what you start with. Here is how this tool compares with two popular free pages, including the places where they do more.

Feature comparison of free online HTML to PDF converters
FeatureScreenshotAPI.netPdfcrowdSmallpdf
Paste HTML codeYesYesNo
Upload an .html fileYesYesYes
Convert from a URLSeparate toolYesNo
Paper size and landscapeYesPaid licenseNo
Custom margins, footers, and page numbersNoPaid licenseNo
Upload a zip with images and CSSNoYesNo

Based on each tool's public HTML to PDF page, checked October 2026. Pdfcrowd's inputs are free, but its settings panel, which holds page size, orientation, margins, and footer page numbers, is locked until you buy a license, and free output carries Pdfcrowd branding. For a URL, ScreenshotAPI.net has a separate webpage to PDF converter.

HTML to PDF FAQ

Common questions about converting HTML code and HTML files to PDF, missing images, and automating it with the ScreenshotAPI.net API.

Don't see your question here?

Browse all help articles