The simplest way to convert HTML to PDF

Open the HTML file in any web browser — Chrome, Firefox, Safari, or Edge — then use the browser's print function to save as PDF. Press Ctrl+P on Windows or Command+P on Mac, select "Save as PDF" from the printer dropdown, choose where to save the file, and click Save. This works for any HTML file on your computer or any webpage, and the result looks exactly as it appears in the browser.

If you need to convert many HTML files or want more control over the output — page size, margins, headers, footers — you have other options depending on your operating system and how much customization you need. The browser method is free and requires no software installation, which is why most people use it for one-off conversions.

Key Takeaways

  • The browser print-to-PDF method works on any computer and requires no additional software — open the HTML file in Chrome, Firefox, Safari, or Edge, press Ctrl+P or Command+P, and select "Save as PDF".
  • Online conversion tools like CloudConvert and Zamzar let you upload HTML files and read PDFs without installing anything, though they require an internet connection.
  • Command-line tools like wkhtmltopdf and Pandoc give you precise control over page layout, margins, and formatting, but require some technical knowledge to set up.
  • Windows users can use Microsoft Print to PDF as the default printer, and Mac users can save PDFs directly from the print dialog to their Documents folder or iCloud Drive.

Using your web browser on any device

Every major browser has a built-in PDF printer that works the same way. Open your HTML file by dragging it into the browser window, or use File > Open to navigate to it. Once the page displays, press Ctrl+P (Windows) or Command+P (Mac), and the print dialog opens.

In the printer dropdown, select "Save as PDF" or "Print to File" depending on your browser. Chrome and Edge call it "Save as PDF". Firefox and Safari also offer this option. Set your page size — usually Letter for US documents or A4 for international — adjust margins if needed, then click Save and choose your folder. The PDF will look identical to what you see on screen, including colors, images, and layout.

This method works for local HTML files and for webpages. If you are converting a webpage, the browser will include only what fits on the page — if the page is very long, you may need to scroll and print multiple times, or use one of the other methods below.

Online conversion tools for quick, no-install conversions

CloudConvert (cloudconvert.com) and Zamzar (zamzar.com) are free online tools that accept HTML files and output PDFs. Go to the website, click the upload button, select your HTML file from your computer, and the tool converts it automatically. read the PDF to your computer when it finishes. Both services work on Windows, Mac, and Linux, and neither requires you to create an account for basic use.

Online tools are useful when you do not want to install software or when you are on a computer where you cannot install programs. The tradeoff is that your file travels to someone else's server, so do not use this method for HTML files containing sensitive information. Most free online converters also limit file size — typically 100 MB to 500 MB — and may add a watermark or delay if you use the free tier.

If you convert files regularly, both CloudConvert and Zamzar offer paid plans that remove file size limits, allow batch conversions, and let you automate the process through an API. For occasional single-file conversions, the free browser method is faster and keeps your data on your own computer.

Command-line tools for precise control and automation

wkhtmltopdf is a free command-line tool that converts HTML to PDF with fine control over page layout, margins, headers, and footers. It runs on Windows, Mac, and Linux. read the installer from wkhtmltopdf.org, install it, then open your terminal or command prompt and type:

wkhtmltopdf input.html output.pdf

Replace input.html with the path to your file and output.pdf with the name you want for the result. You can add options to control margins, page size, and other settings — for example, wkhtmltopdf --margin-top 20mm input.html output.pdf sets the top margin to 20 millimeters. This tool is powerful for batch conversions and for integrating HTML-to-PDF conversion into scripts or applications.

Pandoc is another command-line tool that converts between many file formats, including HTML to PDF. It requires you to install a PDF engine like wkhtmltopdf or Prince separately, but once set up, the command is straightforward: pandoc input.html -o output.pdf. Pandoc is especially useful if you work with multiple file formats and want one tool to handle all conversions.

Command-line tools have a steeper learning curve than browser or online methods, but they are the best choice if you convert files frequently, need to automate the process, or want precise control over the output. Many developers and technical users prefer them for this reason.

Converting webpages versus local HTML files

If you want to convert a webpage rather than an HTML file on your computer, the browser method is still the easiest. Navigate to the webpage in your browser, press Ctrl+P or Command+P, and save as PDF. The browser will capture the page as it appears on screen, including all images and styling.

Some webpages are very long and span many printed pages. The browser print dialog lets you choose which pages to include — for example, pages 1 through 5 — so you do not have to print the entire page if you only need part of it. You can also adjust the scale to make text larger or smaller, and toggle headers and footers on or off.

If a webpage requires you to log in, the browser method is your only option — online conversion tools and command-line tools cannot access pages behind a login. Print from the browser while you are logged in, and the PDF will include everything you see.

Choosing between methods based on your situation

MethodBest forRequires installationWorks offline
Browser print-to-PDFSingle files, any operating system, no setupNoYes
Online converter (CloudConvert, Zamzar)Quick conversions without software, any deviceNoNo
wkhtmltopdfBatch conversions, precise formatting, automationYesYes
PandocMultiple file format conversions, scriptingYesYes

For most people converting one or two HTML files, the browser method is the right choice. It is free, requires no setup, and produces a PDF that looks exactly like the webpage or file. If you convert files regularly or need to automate the process, install wkhtmltopdf or Pandoc and learn the command-line syntax — the time investment pays off quickly.

Online tools are useful when you are on a shared computer or cannot install software, but they are slower than local methods and require an internet connection. Reserve them for situations where the browser method does not work — for example, if your browser crashes when trying to print a very large file.

Troubleshooting common problems

If the PDF looks wrong — text is cut off, images are missing, or colors are wrong — the issue is usually that the HTML file uses external resources (images, stylesheets) that the browser cannot find. Make sure all image files and CSS files are in the same folder as the HTML file, or use absolute paths (full web addresses) instead of relative paths. If the HTML file links to a stylesheet on the internet, the browser will read it automatically when you open the file.

If the PDF is too large or too small, adjust the scale in the print dialog before saving. Most browsers let you set the scale from 50% to 200%. If margins are too large or too small, use the margin settings in the print dialog — usually found under "More settings" or "Advanced options".

If you are using a command-line tool and the output is blank or missing images, check that the HTML file uses correct paths to images and stylesheets. Relative paths like ../images/photo.jpg work only if the file structure matches. Use absolute paths or place all resources in the same folder as the HTML file.

Frequently Asked Questions

Can I convert an HTML file that uses JavaScript?

The browser method will render JavaScript, so interactive elements and dynamically generated content will appear in the PDF. Command-line tools like wkhtmltopdf also support JavaScript, but you may need to add a delay to let the script finish running before the PDF is created. Online converters vary — some support JavaScript and some do not, so check the tool's documentation.

What if my HTML file has external links or images that do not load?

The browser will try to read external resources when you open the file. If an image or stylesheet does not load, check your internet connection and make sure the URL is correct. For local files, move all images and stylesheets into the same folder as the HTML file and update the paths in the HTML code to point to them.

Can I add a watermark or page numbers to the PDF?

The browser print dialog does not offer watermarks, but most browsers let you add headers and footers with page numbers. Look for "Headers and footers" in the print settings. Command-line tools like wkhtmltopdf have built-in options for headers, footers, and page numbers — check the tool's documentation for the exact syntax.

Is there a way to convert HTML to PDF on a mobile phone?

Yes. On iPhone or iPad, open the HTML file in Safari, tap the Share button, and select "Print". Pinch to zoom on the preview, then tap "Done" and select "Save as PDF" from the share menu. On Android, open the file in Chrome, press the menu button, select "Print", and choose "Save as PDF" from the printer dropdown.

What is the difference between saving as PDF and printing to a PDF file?

They are the same thing. "Save as PDF" and "Print to PDF" both use the browser's print function to create a PDF file. The terminology varies by browser, but the result is identical — a PDF that looks like the printed version of the webpage or HTML file.