HTML to PDF converter
Paste HTML or open a file, choose the page size, and download the PDF. Free, no signup.
This free HTML to PDF converter prints your HTML with headless Chromium, the browser engine behind the ASHDOCS HTML to PDF API, so CSS layout, web fonts embedded as data URIs, tables and print rules such as page breaks render the way they do in Chrome's print preview.
Chromium print engine
Flexbox, grid, @page size and margins, and page-break rules print as Chrome prints them.
Safe by design
The free converter renders with the network and JavaScript turned off: inline CSS and data: images print, remote files and scripts do not.
A4 or Letter, portrait or landscape
Pick the paper and orientation; a CSS @page size in your HTML takes priority.
For developers: HTML to PDF from the API
The API version loads remote images, stylesheets and fonts, renders URLs as well as HTML and returns a signed link to the file.
curl -X POST https://www.ashdocs.com/api/v1/tools/html-to-pdf \
-H "X-API-Key: ash_test_..." \
-F 'options={"html":"<h1>Invoice 42</h1><p>Total due: 120.00 USD</p>"}'const form = new FormData();
form.append("options", JSON.stringify({
html: "<h1>Invoice 42</h1><p>Total due: 120.00 USD</p>",
}));
const res = await fetch("https://www.ashdocs.com/api/v1/tools/html-to-pdf", {
method: "POST",
headers: { "X-API-Key": "ash_test_..." },
body: form,
});
const job = await res.json();
console.log(job.output_files[0].url);import json
import requests
r = requests.post(
"https://www.ashdocs.com/api/v1/tools/html-to-pdf",
headers={"X-API-Key": "ash_test_..."},
data={"options": json.dumps({"html": "<h1>Invoice 42</h1><p>Total due: 120.00 USD</p>"})},
)
print(r.json()["output_files"][0]["url"])<?php
// HTML to PDF with ASHDOCS: needs PHP's curl extension.
$ch = curl_init("https://www.ashdocs.com/api/v1/tools/html-to-pdf");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
"X-API-Key: " . getenv("ASHDOCS_API_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"html" => "<h1>Invoice 42</h1><p>Total due: 120.00 USD</p>",
]),
CURLOPT_RETURNTRANSFER => true,
]);
$job = json_decode(curl_exec($ch), true);
curl_close($ch);
echo $job["output_files"][0]["url"], PHP_EOL;import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
// HTML to PDF with ASHDOCS: Java 11+ standard library. Run with: java Sample.java
public class Sample {
public static void main(String[] args) throws Exception {
String body = "{\"html\": \"<h1>Invoice 42</h1><p>Total due: 120.00 USD</p>\"}";
HttpRequest request = HttpRequest.newBuilder(URI.create("https://www.ashdocs.com/api/v1/tools/html-to-pdf"))
.header("X-API-Key", System.getenv("ASHDOCS_API_KEY"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
// The job record: output_files[0].url is a signed link to the PDF, valid for one hour.
System.out.println(response.body());
}
}using System.Net.Http.Json;
using System.Text.Json;
// HTML to PDF with ASHDOCS: .NET 6+ standard library.
using var http = new HttpClient();
http.DefaultRequestHeaders.Add("X-API-Key", Environment.GetEnvironmentVariable("ASHDOCS_API_KEY"));
var res = await http.PostAsJsonAsync("https://www.ashdocs.com/api/v1/tools/html-to-pdf",
new { html = "<h1>Invoice 42</h1><p>Total due: 120.00 USD</p>" });
using var job = JsonDocument.Parse(await res.Content.ReadAsStringAsync());
Console.WriteLine(job.RootElement.GetProperty("output_files")[0].GetProperty("url").GetString());require "json"
require "net/http"
# HTML to PDF with ASHDOCS: Ruby standard library.
uri = URI("https://www.ashdocs.com/api/v1/tools/html-to-pdf")
request = Net::HTTP::Post.new(uri, {
"X-API-Key" => ENV.fetch("ASHDOCS_API_KEY"),
"Content-Type" => "application/json",
})
request.body = { html: "<h1>Invoice 42</h1><p>Total due: 120.00 USD</p>" }.to_json
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(request) }
job = JSON.parse(response.body)
puts job["output_files"][0]["url"]package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"os"
)
// HTML to PDF with ASHDOCS: Go standard library.
func main() {
body, _ := json.Marshal(map[string]string{
"html": "<h1>Invoice 42</h1><p>Total due: 120.00 USD</p>",
})
req, _ := http.NewRequest("POST", "https://www.ashdocs.com/api/v1/tools/html-to-pdf", bytes.NewReader(body))
req.Header.Set("X-API-Key", os.Getenv("ASHDOCS_API_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
var job struct {
OutputFiles []struct {
URL string `json:"url"`
} `json:"output_files"`
}
if err := json.NewDecoder(res.Body).Decode(&job); err != nil {
panic(err)
}
fmt.Println(job.OutputFiles[0].URL)
}{
"job_id": "job_8c1f2e7a9b3d",
"request_id": "req_5d0a4c9e1f27",
"tool_key": "html-to-pdf",
"status": "completed",
"output_files": [
{
"filename": "output.pdf",
"size": 8214,
"url": "<signed URL, valid for 1 hour>",
"expires_at": "2026-10-09T13:00:00+00:00"
}
],
"credits_consumed": 0,
"is_test": true
}Response trimmed; values illustrative. Test keys report 0 credits; a live key reports 1. The PHP, Java, C#, Ruby and Go tabs send the same request as JSON and read the key from ASHDOCS_API_KEY.
How to use the HTML to PDF converter
Paste a full HTML document or a fragment into the box, or open an .html file. Choose A4 or Letter and, if you need it, landscape. Select Convert to PDF and the file downloads as document.pdf.
Getting the PDF to look right
Most HTML that looks right in Chrome prints right here. A few things help:
- Put styles in a
<style>block or inline; linked stylesheets are not fetched in the free converter. - Embed images and fonts as data URIs for the same reason.
- Use
@page { size: A4; margin: 20mm; }to control the page box, andbreak-before: pageto start a new page. - Background colors and images print, so there is no need for print-specific overrides.
Free, and what needs an API key
The HTML to PDF converter on this page is free with no signup and no watermark, up to 20 PDFs a day from one connection and 2 MB per document. For more, or to render from your own code, the same conversion is one API call; the free plan includes 10 credits a month and test keys never use credits.
What you paste is sent to ASHDOCS only to print the PDF and is not stored. Each PDF made is logged with the IP address, browser and file size for 30 days, to stop abuse of the free tool.
Frequently asked questions
Is the HTML to PDF converter free?
Yes, with no signup and no watermark, up to 20 PDFs a day from one connection and 2 MB per document.
Why are my images missing?
The free converter does not fetch anything from the internet. Embed images as data URIs, or use the API, which loads remote images and stylesheets.
Does JavaScript run?
Not in the free converter. Render the page's final HTML, or use the API for URLs and pages that need scripts.
Can I convert a web page by URL?
URL to PDF needs an API key: the API's URL to PDF tool loads the page in Chromium and prints it.
Related tools
Guide: Why Your HTML to PDF Layout Breaks (and How to Fix It)