How to use Gotenberg with n8n to convert HTML to PDF

How to use Gotenberg with n8n to convert HTML to PDF

Gotenberg with n8n: use the HTTP Request node to turn HTML into PDFs in a workflow, or skip the server with a hosted API and one JSON call.

Quick answer. In n8n, add one HTTP Request node that POSTs {"html": "..."} to https://html-pdf.com/v1/pdf with your key, and set the response format to File. The same request as curl looks like this.

curl -X POST https://html-pdf.com/v1/pdf \
  -H "Authorization: Bearer $HTML_PDF_KEY" \
  -H "Content-Type: application/json" \
  -d '{"html": "<h1>Hello</h1>", "format": "A4"}' \
  -o out.pdf

Option A: your own Gotenberg

This option walks you through calling a Gotenberg server you run yourself. You need a Gotenberg instance that n8n can reach (see self-host Gotenberg with Docker or deploy it on Railway). If both run in the same Docker network, the URL is usually http://gotenberg:3000.

1. Turn your HTML into a file named index.html

Gotenberg's HTML route only accepts an uploaded file called index.html. Here is how to create it in n8n.

  1. Build your HTML (for example in a Code or Set node) into a field such as html.
  2. Add a Convert to File node with operation Move String to File, source property html, file name index.html and MIME type text/html. This creates binary data (by default in the data property).

2. Send it to Gotenberg

Add an HTTP Request node with these settings.

The output item now carries the PDF as binary data. It is ready for Gmail, Google Drive, S3 or a webhook response.

Common errors

Option B: skip the server (one JSON call)

This option gets you PDFs with no file conversion step and nothing to host. With html-pdf.com you need a single HTTP Request node.

Prefer a link instead of binary data? Add "response": "url" to the body and use {{ $json.url }} downstream. The link stays valid for 24 hours.

You get 100 free pages, then pay from $0.005 per page, and credits never expire. For the full walkthrough, see HTML to PDF in n8n.

Get a free API key · API reference

FAQ

How do I convert HTML to PDF in n8n?

Use an HTTP Request node. Either upload an index.html file to your own Gotenberg server, or POST JSON with your HTML to https://html-pdf.com/v1/pdf and set the response format to File.

Why does Gotenberg return "no index.html"?

Gotenberg's HTML route needs the uploaded file to be named exactly index.html. Set that file name in the Convert to File node.

Is there a free way to generate PDFs in n8n without a server?

Yes. html-pdf.com gives you 100 free credits once, with no card, and 1 credit = 1 PDF page. Purchased credits never expire.

Yes. Add "response": "url" to the JSON body and read {{ $json.url }} in the next node. The link lasts 24 hours.

This page as markdown · text