ScreenshotNeo

BlogHTML to image & PDF

HTML Code to PDF Converter Online Free

Convert HTML to PDF online for free: private browser tools, API workflows, CSS fixes, limits, troubleshooting, and automation options.

By the ScreenshotNeo team1 October 20267 min read

HTML Code to PDF Converter Online Free

For a one-off conversion, use a browser-based HTML-to-PDF converter that renders locally. Paste your markup or open an .html file, choose the paper size and margins, then download the PDF. PDF Edit says its converter runs entirely in the browser, so the file does not leave your device.

For recurring documents, public URLs, or automated jobs, use an HTML-to-PDF API. APIs accept raw HTML or a URL and can expose controls for paper format, margins, JavaScript, and print rendering. Free limits differ widely, so check payload size, page count, rate limits, watermarks, retention, and authentication before choosing one.

Choose the right free approach

Use case Best fit Why Watch for
Private, one-off HTML Local browser converter Processing stays on the device according to PDF Edit Browser print behavior and limited automation
Repeated jobs or an application Hosted API HTTP requests can run from CI, servers, and scripts Quotas, retention, rate limits, and authentication
Modern JavaScript pages Chromium-based renderer Better support for client-side rendering and web fonts Delayed scripts, blocked assets, and login requirements
Free demonstrations SelectPdf or similar demo Quick test without setting up an account SelectPdf documents a five-page limit and watermark

Convert HTML to PDF online in a browser

  1. Open a browser converter that supports local HTML, such as PDF Edit.
  2. Paste the complete HTML document or drop an .html/.htm file into the page.
  3. Set the page format to A4 or Letter, then choose portrait or landscape orientation.
  4. Set margins. Start with the default margin, then reduce it only if your layout needs more width.
  5. Enable background graphics if your design relies on color blocks, gradients, or background images.
  6. Generate the PDF and open it in a PDF viewer. Check every page before sharing it.

A local workflow is the clearest option for confidential source because PDF Edit says files never leave the device and that conversion can work offline. Treat that as a provider claim and review the current privacy details before uploading sensitive material to any service.

A local browser converter can keep a one-off HTML document on the device.
A local browser converter can keep a one-off HTML document on the device.

Minimal HTML that prints cleanly

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Invoice 1042</title>
  <style>
    @page { size: A4; margin: 16mm; }
    * { box-sizing: border-box; }
    body {
      margin: 0;
      color: #172033;
      font: 14px/1.5 Arial, sans-serif;
    }
    h1 { margin: 0 0 8px; font-size: 28px; }
    .muted { color: #667085; }
    .total { margin-top: 24px; font-size: 20px; font-weight: 700; }
    @media print {
      .screen-only { display: none !important; }
      .avoid-break { break-inside: avoid; }
    }
  </style>
</head>
<body>
  <h1>Invoice 1042</h1>
  <p class="muted">Issued 2026-10-01</p>
  <section class="avoid-break">
    <p>Design and development services</p>
    <p class="total">Total: $1,250.00</p>
  </section>
</body>
</html>

Convert a public HTML URL with an API

Use a URL when the document is already hosted and can be fetched without a login. Use raw HTML when your application generates the markup dynamically. HTMLPDF.dev documents POST /api/pdf with either html or url (not both), plus format and margin parameters.

cURL

curl -X POST "https://htmlpdf.dev/api/pdf" \
  -H "Content-Type: application/json" \
  --data '{
    "url": "https://example.com/invoice/1042",
    "format": "A4",
    "margin": {
      "top": "16mm",
      "right": "16mm",
      "bottom": "16mm",
      "left": "16mm"
    }
  }' \
  -o invoice-1042.pdf

Python

import requests

payload = {
    "html": "<html><body><h1>Invoice 1042</h1></body></html>",
    "format": "A4",
    "margin": {
        "top": "16mm",
        "right": "16mm",
        "bottom": "16mm",
        "left": "16mm",
    },
}

response = requests.post("https://htmlpdf.dev/api/pdf", json=payload, timeout=90)
response.raise_for_status()
with open("invoice-1042.pdf", "wb") as pdf:
    pdf.write(response.content)

Node.js

const payload = {
  url: 'https://example.com/invoice/1042',
  format: 'A4',
  margin: { top: '16mm', right: '16mm', bottom: '16mm', left: '16mm' }
};

const response = await fetch('https://htmlpdf.dev/api/pdf', {
  method: 'POST',
  headers: { 'content-type': 'application/json' },
  body: JSON.stringify(payload)
});

if (!response.ok) throw new Error(`HTTP ${response.status}`);
const pdf = Buffer.from(await response.arrayBuffer());
require('node:fs').writeFileSync('invoice-1042.pdf', pdf);

HTMLPDF.dev documents a free quota of 100 PDFs per month and a limit of 10 requests per hour. Other free services publish different constraints: Ironfang lists a 256 KB HTML limit, a 30-second render timeout, and 20 renders per hour per address; PDFSpark lists a 5 MB HTML limit; SelectPdf’s no-signup demo is limited to five pages and adds a watermark.

Control page size, margins, and print layout

  • Paper: Use A4 for most international documents and Letter for US workflows. Define it in @page or the provider’s format option.
  • Orientation: Choose landscape for wide tables, but also make the content responsive so it does not overflow.
  • Margins: Keep important content inside the printable area. Large fixed-width containers are a common cause of clipped columns.
  • Print colors: Enable background graphics in the converter and check @media print rules if colors disappear.
  • Page breaks: Use break-before, break-after, and break-inside: avoid for headings, cards, and table rows.
  • Headers and footers: Use the provider’s header/footer options when available; otherwise place repeating information in the document itself.
@page {
  size: Letter landscape;
  margin: 12mm 14mm;
}

.report-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

.report-section,
.report-table tr {
  break-inside: avoid;
}

@media print {
  a { color: inherit; text-decoration: none; }
  .screen-only { display: none; }
}

JavaScript, external assets, and relative URLs

Modern browser engines can execute client-side JavaScript, but the PDF is generated at a particular moment. If your page fills in data after load, wait for that state before printing. A page that depends on a login, private network, or bot check may render blank or incomplete.

Images, fonts, and stylesheets must be reachable by the rendering engine. Prefer absolute HTTPS URLs for hosted conversion, or embed critical CSS and small images directly. Relative paths often break when the renderer has no browser address to resolve them against.

Privacy and security

Local conversion keeps the source on your device according to PDF Edit. Hosted conversion sends the HTML or URL to a provider. Ironfang says HTML is rendered on UK servers and discarded after the response; still review retention, logging, access controls, and jurisdiction terms for the service you select.

Or skip the browser setup

For a hosted page that needs a repeatable screenshot or PDF capture, ScreenshotNeo provides a single HTTP request and PDF options. See the ScreenshotNeo API documentation for the current parameters.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
  • Cookie banners, newsletter popups, and chat widgets are removed before the shot.
  • Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed; response headers identify the page verdict and billing result.
  • An MCP server lets AI agents use take_screenshot, get_page_info, and capture_pdf.
  • 1,000 screenshots per month are free with no card; paid plans start at $5 for 3,000 shots.

Create a free ScreenshotNeo account.

Troubleshooting

Symptom Likely cause Fix
Content is cut off Fixed width exceeds the paper box Use responsive widths, reduce margins, or switch to landscape.
Blank PDF JavaScript has not finished, or the page requires authentication Wait for rendered content, provide permitted access, or convert the generated HTML directly.
Images are missing Relative paths, private URLs, hotlink protection, or blocked requests Use absolute URLs, embed small assets, and verify the renderer can reach them.
Colors disappear Print backgrounds are disabled or print CSS overrides screen CSS Enable background graphics and inspect @media print.
Request rejected HTML exceeds payload or page quota Check the provider’s documented byte, page, timeout, and rate limits.
Watermark appears Free demo restriction Use a local converter or a plan/API that does not watermark output.

Performance, reliability, and cost checklist

  • Inline critical CSS and compress large images.
  • Wait for fonts and client-side data before capture.
  • Cache identical documents in your application when the source has not changed.
  • Retry transient network failures with a bounded backoff, but do not retry validation errors.
  • Record page count, response time, provider status, and output size.
  • Keep a local fallback for confidential or time-sensitive documents.
  • Estimate monthly volume against free quotas before committing to an API.

Free HTML-to-PDF services at a glance

Service Processing model Documented free limits or notes
PDF Edit Local browser Says processing is 100% in-browser and files never leave the device.
HTMLPDF.dev Hosted API and browser playground 100 PDFs/month and 10 requests/hour; accepts HTML or URL.
Ironfang Hosted Chromium renderer 256 KB input, 30-second timeout, 20 renders/hour per address; says data is discarded after rendering.
SelectPdf Hosted demo No signup, five-page maximum, watermark.
PDFSpark Unauthenticated hosted API 5 MB maximum HTML payload.
H2P Open-source REST option Advertises permissive commercial use.

FAQ

Can I convert HTML without installing software?

Yes. A browser converter handles a pasted document or local file. An API handles URLs or generated HTML from a script.

Which option is safest for confidential HTML?

A local browser workflow is the clearest choice when its no-upload claim matches your needs. Hosted services receive your markup or URL.

Why does my PDF look different from the webpage?

PDF rendering uses print CSS, a fixed paper box, and a capture-time snapshot. Check print rules, viewport width, delayed scripts, and external assets.

Can a free service handle a production queue?

Only if its quotas and reliability match your volume. Measure page size, render time, rate limits, and retry behavior before moving a queue to production.

Can I automate PDF generation from a URL?

Yes. Use a documented API such as HTMLPDF.dev’s POST /api/pdf, or use ScreenshotNeo for supported capture and PDF workflows.