Google Docs
What this guide covers
This guide walks you through merging a Google Docs exported .docx template in n8n using google-docs-template.docx and google-docs-data.json. The template uses mustache placeholders ({{name}}, {{course}}, etc.). Data is a JSON array with one object per row. For Generate Document (Single), use one object in the array. Output can be PDF or Word.
Before You Start
google-docs-template.docx is a course certificate with {{name}}, {{course}}, {{date}}, and {{instructor}}.google-docs-data.json (recommended), test.xml, or test.csv. Like Mail Merge, Google Docs data is an array of objects. For one certificate, paste an array with a single object.Google Docs is for .docx files exported from Google Docs with mustache {{field}} placeholders. PDF4me Word Template uses <<[fieldName]>> LINQ syntax. Mail Merge uses classic Word MERGEFIELD codes. Pick the type that matches how your template was built.
Sample File Pack
Download all four files below. One exported Google Docs template plus three equivalent data formats.
What's Inside the Sample Files
Placeholders in google-docs-template.docx
The sample is a course completion certificate with four mustache merge fields:
| Mustache placeholder | Certificate label in template | Sample value (google-docs-data.json) |
|---|---|---|
{{name}} | Participant name | Alice Johnson |
{{course}} | Course title | Intro to Automation |
{{date}} | Completion date | 2026-03-10 |
{{instructor}} | Instructor name | Mr. Smith |
Type placeholders directly in Google Docs as plain text, for example {{name}}. After export to .docx, PDF4me replaces each tag with the matching JSON key. This is the same mustache style as HTML templates, but the file format is Word, not HTML.
Field mapping across all data files
| Placeholder | JSON key (google-docs-data.json) | XML element (test.xml) | CSV column (test.csv) | Sample value |
|---|---|---|---|---|
{{name}} | name | name | name | Alice Johnson |
{{course}} | course | course | course | Intro to Automation |
{{date}} | date | date | date | 2026-03-10 |
{{instructor}} | instructor | instructor | instructor | Mr. Smith |
Unlike PDF4me Word Template, there are no <<[field]>> tags. Unlike Mail Merge, there are no MERGEFIELD codes. Keys in your JSON array objects map to {{field}} placeholders one to one.
The Workflow at a Glance
Manual Trigger → Read Binary File (google-docs-template.docx) → PDF4me Generate Document (Single) → (optional) Write Binary File
| Step | n8n node | Purpose |
|---|---|---|
| 1 | Manual Trigger | Start the workflow on demand |
| 2 | Read Binary File | Loads google-docs-template.docx into binary property data |
| 3 | PDF4me → Generate Document (Single) | Merges template + JSON array, outputs PDF or Word |
| 4 | Write Binary File or Send Email (optional) | Saves or sends generated_document_output.pdf |
/generate-document-single-template-file-type.png)
Set Template File Type to Google Docs. Choose PDF or Word for Output Type.
Step 1: Download and Place the Sample Files
- Download
google-docs-template.docxandgoogle-docs-data.jsonfrom the Sample File Pack above. - Save the template somewhere n8n can read it (local path on self-hosted, or cloud storage for production triggers).
- Optionally download
test.xmlortest.csvto test other data types.
To use your own Google Doc: open it in Google Docs, choose File → Download → Microsoft Word (.docx), and use that file as your template.
Step 2: Create the n8n Workflow
- In n8n, create a new workflow.
- Add a Manual Trigger node.
- Add a Read Binary File node after the trigger.
- Add PDF4me → Generate Document (Single) after Read Binary File.
- Connect your PDF4me credential.
Template File Input Type: HTML Code only works when Template File Type is HTML. For Google Docs, use Binary Data, Base64 String, or URL.
Step 3: Load the Template (Read Binary File)
Configure the Read Binary File node:
| Field | Value |
|---|---|
| File Path | Full path to your downloaded google-docs-template.docx |
| Property Name | data (default; used as Template Binary Property in PDF4me) |
Execute this node once and confirm the output item shows binary data with filename google-docs-template.docx.
Step 4: Configure PDF4me Generate Document (Single)
Core settings
| Field | Value | Notes |
|---|---|---|
| Credential to connect with | Your PDF4me credential | Get API key |
| Resource | Generate | |
| Generate Operations | Generate Document (Single) | |
| Template File Type | Google Docs | Exported Google Docs .docx with mustache tags |
| Output Type | PDF or Word | PDF for sharing; Word if the recipient should edit the merged document |
Template input (from Read Binary File)
| Field | Value |
|---|---|
| Template File Input Type | Binary Data |
| Template Binary Property | data |
| Template File Name | google-docs-template.docx |
Document data (paste JSON array from google-docs-data.json)
| Field | Value |
|---|---|
| Document Data Input Type | Text |
| Document Data Type | JSON |
| Document Data Text | Paste the full contents of google-docs-data.json (see block below) |
[
{
"name": "Alice Johnson",
"course": "Intro to Automation",
"date": "2026-03-10",
"instructor": "Mr. Smith"
}
]
Google Docs template data is a JSON array, even for a single certificate. One object in the array produces one merged document with Generate Document (Single).
Output options
| Field | Value |
|---|---|
| Keep PDF Editable | Off (default) when Output Type is PDF |
| Binary Data Output Name | data (default) |
Step 5: Execute and Verify the Output
- Click Execute workflow.
- Open the PDF4me node output. Under Binary, open property
data(generated_document_output.pdfor.docx). - Confirm all four placeholders are filled:
- name → Alice Johnson
- course → Intro to Automation
- date → 2026-03-10
- instructor → Mr. Smith
If a field is blank, compare your JSON keys with the mustache tags in the exported .docx character by character.
Step 6: Save or Send the Output (Optional)
Write Binary File:
| Field | Value |
|---|---|
| File Name | certificate-output.pdf |
| Data Property Name | data |
| Output Path | Target folder on your n8n host |
Send Email: attach the binary data from PDF4me as the PDF or Word attachment.
Alternative Data Formats
Option A: JSON file as binary (google-docs-data.json)
- Add Read Binary File for
google-docs-data.json(use a Merge node if template and data share the workflow item). - Set Document Data Input Type to Binary Data, Document Data Type to JSON, Document Binary Property to your data field, Document Data File Name to
google-docs-data.json.
If both template and data use property data, one overwrites the other. Use separate names (e.g. template and rowData) or merge items from two Read Binary File nodes.
Option B: XML (test.xml)
Set Document Data Type to XML and paste one record (the sample file contains two; use the first for a single run):
<?xml version="1.0" encoding="UTF-8"?>
<Records>
<Record>
<name>Alice Johnson</name>
<course>Intro to Automation</course>
<date>2026-03-10</date>
<instructor>Mr. Smith</instructor>
</Record>
</Records>
Element names match the mustache keys and JSON properties.
Option C: CSV (test.csv)
Set Document Data Type to CSV and paste (header row + one data row):
name,course,date,instructor
"Alice Johnson","Intro to Automation","2026-03-10","Mr. Smith"
Column headers match the mustache placeholder names directly.
Alternative Template Input: URL
Host google-docs-template.docx at a public HTTPS URL, then set:
| Field | Value |
|---|---|
| Template File Input Type | URL |
| Template File URL | Public link to google-docs-template.docx |
| Template File Name | google-docs-template.docx |
No Read Binary File node is required. Data can still be pasted as Document Data Text or loaded from a URL.
Production Workflow Patterns
Common ways to generate from Google Docs templates in productionOnce the sample test works, replace the Manual Trigger with these patterns.
- Sheets trigger on new completion row.
- Code node wraps the row in a JSON array:
[{"name": "...", "course": "...", ...}]. - PDF4me Google Docs with fixed
google-docs-template.docxfrom binary or URL. - Email the merged PDF to the participant.
- New JSON file lands in a watched folder.
- Load the fixed Google Docs template from the same folder or a URL.
- Pass file contents as Document Data (Binary Data or Text).
- Upload output PDF to an Output folder. See the Zapier trigger blog for a similar pattern.
- Export participants as a JSON array (one object per person).
- Switch to Generate Documents (Multiple) for one PDF per row.
- Keep Generate Document (Single) when you only need one merged file per run.
Frequently Asked Questions
Related Guides
- Generate Document (Single) overview: all parameters, output fields, and template types
- PDF4me Word Template:
<<[fieldName]>>syntax instead of mustache - Mail Merge: classic Word MERGEFIELD templates
- Generate Documents (Multiple): one output file per row in your JSON array
- Google Docs workflow (Make): four-step manual flow in Make