Overview
This node fills a DOCX template with JSON data. It takes a DOCX file from the input binary data, uses JSON-formatted data to replace placeholders in the template, and outputs a new DOCX document with the data filled in.
Common scenarios include:
- Generating personalized reports or letters by merging user data into a predefined DOCX template.
- Automating document creation workflows where templates are reused but content varies.
- Creating invoices, certificates, or contracts dynamically based on input data.
For example, you could provide a DOCX template with placeholders like {{name}} and supply JSON data { "name": "John Doe" }. The node will produce a DOCX file with "John Doe" inserted in place of the placeholder.
Properties
| Name | Meaning |
|---|---|
| Template Key | The binary key name where the DOCX template is stored in the input item. Supports deep keys using dot-notation (e.g., level1.level2.currentKey). |
| Output Key | The binary key name where the filled DOCX document will be saved in the output item. Supports deep keys using dot-notation (e.g., level1.level2.newKey). |
| Input Data | A string containing JSON data used to fill the template. You must stringify your data before passing it here (e.g., use JSON.stringify(data)). |
| Output File Name | The filename for the generated DOCX document, without the extension. The node appends .docx automatically. |
Output
The node outputs items with the following structure:
json: An empty object{}(no JSON data output).binary: Contains the filled DOCX document under the specified output key. This binary data represents the generated DOCX file ready for download or further processing.
Dependencies
- Uses the
easy-template-xlibrary to process DOCX templates. - Requires input items to contain binary data with the DOCX template.
- No external API or service dependencies.
- Requires proper configuration of input binary data keys and valid JSON string input for data.
Troubleshooting
- Error parsing template data: If the JSON string provided in "Input Data" is invalid or malformed, the node throws an error indicating failure to parse the data. Ensure your JSON string is correctly formatted.
- No binary data exists on item: The node expects the input item to have binary data at the specified template key. If missing, this error occurs. Verify that the input contains the DOCX template binary data under the correct key.
- Unsupported image format: When embedding images in the template data, only PNG and JPG formats are supported. Using other formats will cause an error.
- Error filling the document: General errors during template processing may occur if the template is corrupted or the data does not match placeholders. Check the template integrity and data structure.
Links and References
- easy-template-x GitHub repository – Documentation for the templating engine used.
- DOCX file format overview – Background on DOCX files.
- n8n documentation on binary data handling – How to manage binary data in n8n nodes.