N8N node for dynamic text templating using Mustache, Handlebars, Nunjucks, and EJS engines - perfect for AI prompts, email automation, and report generation
npm install n8n-nodes-text-templaterTransform your N8N workflows with powerful text templating - Generate dynamic content using Mustache, Handlebars, Nunjucks, or EJS template engines for AI prompts, email automation, reports, and more.




---
- Why Text Templater?
- Key Features
- Installation
- Quick Start Guide
- Templating Engines
- Use Cases
- Examples
- Configuration
- Best Practices
- Troubleshooting
- Contributing
- License
---
The N8N Text Templater is a must-have community node for anyone building automated workflows that require dynamic text generation. Whether you're creating AI prompts, personalizing emails, generating reports, or building API requests, this node provides professional-grade templating capabilities directly in your N8N workflows.
- AI & LLM Integration - Generate dynamic prompts for ChatGPT, Claude, GPT-4, and other AI models
- Email Marketing - Personalize bulk emails with customer data and conditional content
- Report Generation - Create formatted reports with charts, tables, and dynamic data
- API Development - Build dynamic JSON/XML payloads for REST APIs
- Documentation - Auto-generate technical docs, release notes, and changelogs
- Content Creation - Produce blog posts, social media content, and marketing copy
- Workflow Automation - Transform data between services with custom formatting
---
| Engine | Best For | Complexity | Performance |
|--------|----------|-----------|-------------|
| Mustache | Simple substitution | Beginner | ā” Fastest |
| Handlebars | Logic & loops | Intermediate | ā” Fast |
| Nunjucks | Filters & inheritance | Advanced | š„ Medium |
| EJS | JavaScript power | Expert | š„ Medium |
eval() or arbitrary code execution (except EJS)={{$json.field}})---
The easiest way to install the Text Templater node:
1. Open your N8N instance
2. Navigate to Settings ā Community Nodes
3. Click "Install a community node"
4. Enter: n8n-nodes-text-templater
5. Click Install and wait for completion
6. Refresh your browser
For self-hosted N8N installations:
``bashNavigate to your N8N custom nodes directory
cd ~/.n8n/nodes
$3
Add to your
docker-compose.yml or environment variables:`yaml
services:
n8n:
image: n8nio/n8n
environment:
- N8N_COMMUNITY_PACKAGES=n8n-nodes-text-templater
ports:
- "5678:5678"
`Or use environment variable:
`bash
docker run -it --rm \
-e N8N_COMMUNITY_PACKAGES=n8n-nodes-text-templater \
-p 5678:5678 \
n8nio/n8n
`$3
For developers who want to modify the node:
`bash
Clone the repository
git clone https://github.com/llmx-de/n8n-nodes-text-templater.git
cd n8n-nodes-text-templaterInstall dependencies
npm installBuild the node
npm run buildLink for development
npm link
cd ~/.n8n/nodes
npm link n8n-nodes-text-templaterRestart N8N
n8n restart
`---
š Quick Start Guide
$3
1. Click the "+" button in your N8N workflow
2. Search for "Text Templater" or "template"
3. Select the Text Templater node
$3
Choose from Mustache, Handlebars, Nunjucks, or EJS based on your needs:
- Mustache: For simple variable replacement
- Handlebars: For conditional content and loops
- Nunjucks: For filters and template inheritance
- EJS: For full JavaScript expressions
$3
Enter your template with placeholders for dynamic data:
`handlebars
Hello {{name}}!Your order #{{orderId}} has been confirmed.
`$3
Add your data as JSON:
`json
{
"name": "John Doe",
"orderId": "12345"
}
`$3
Click "Execute node" to see your rendered template:
`
Hello John Doe!Your order #12345 has been confirmed.
`---
šØ Templating Engines
$3
Use Mustache when: You need simple variable substitution without complex logic.
Syntax:
{{variable}}Features:
- ā
Variable substitution
- ā
Sections (loops and conditionals)
- ā
Comments
- ā
Partials
- ā No complex logic
- ā No custom helpers
Example:
`handlebars
Hello {{name}}!Your order #{{orderId}} has been {{status}}.
{{#premium}}
š Thank you for being a premium member!
Enjoy your {{discount}}% discount.
{{/premium}}
{{^premium}}
š” Upgrade to premium for exclusive benefits!
{{/premium}}
`Variables:
`json
{
"name": "Alice Smith",
"orderId": "ORD-12345",
"status": "shipped",
"premium": true,
"discount": 20
}
`Output:
`
Hello Alice Smith!Your order #ORD-12345 has been shipped.
š Thank you for being a premium member!
Enjoy your 20% discount.
`Learn more: Mustache Documentation
---
$3
Use Handlebars when: You need conditional logic, loops, and custom formatting.
Syntax:
{{#if}}, {{#each}}, helpersFeatures:
- ā
All Mustache features
- ā
If/else conditionals
- ā
Each loops with @index
- ā
Built-in helpers
- ā
Custom helper support
- ā
Block expressions
Example:
`handlebars
Order Summary for {{customer.name}}
{{#if customer.isPremium}}
VIP Customer š
Loyalty Points: {{customer.points}}
Discount Rate: {{customer.discountRate}}%
{{else}}
Standard Customer
{{/if}}Items Ordered
{{#each items}}
{{@index}}. {{this.name}} - ${{this.price}} x {{this.quantity}}
Subtotal: ${{multiply this.price this.quantity}}
{{/each}}
---
Total: ${{total}}
{{#if customer.isPremium}}
After {{customer.discountRate}}% discount: ${{discountedTotal}}
{{/if}}
`Variables:
`json
{
"customer": {
"name": "Bob Johnson",
"isPremium": true,
"points": 1250,
"discountRate": 15
},
"items": [
{"name": "Laptop", "price": 999, "quantity": 1},
{"name": "Mouse", "price": 25, "quantity": 2}
],
"total": 1049,
"discountedTotal": 891.65
}
`Learn more: Handlebars Documentation
---
$3
Use Nunjucks when: You need advanced formatting, filters, and template inheritance.
Syntax:
{% if %}, {{ var | filter }}Features:
- ā
Jinja2-inspired syntax
- ā
Powerful filters (upper, lower, replace, etc.)
- ā
Template inheritance
- ā
Macros and includes
- ā
Async support
- ā
Autoescape for security
Example:
`nunjucks
Welcome {{ name | title }}!
{% if memberSince %}
Member since: {{ memberSince | date("MMMM YYYY") }}
Status: {{ status | upper }}
{% endif %}
Your Recent Activity
{% for activity in activities %}
- {{ activity.date | date("MMM DD") }}: {{ activity.description }}
{% if activity.important %}ā Important{% endif %}
{% endfor %}
{% if activities | length > 5 %}
Showing 5 of {{ activities | length }} activities.
{% endif %}
---
Email: {{ email | lower }}
Phone: {{ phone | default("Not provided") }}
`Variables:
`json
{
"name": "charlie brown",
"memberSince": "2023-01-15",
"status": "gold",
"email": "Charlie.Brown@EXAMPLE.com",
"activities": [
{"date": "2025-11-01", "description": "Logged in", "important": false},
{"date": "2025-11-05", "description": "Made purchase", "important": true}
]
}
`Learn more: Nunjucks Documentation
---
$3
Use EJS when: You need full JavaScript power for complex calculations.
Syntax:
<%= expression %>, <% code %>Features:
- ā
Full JavaScript expressions
- ā
Loops and conditionals with JS syntax
- ā
Functions and calculations
- ā
Array/object manipulation
- ā ļø Powerful but less secure
- ā ļø Use only with trusted data
Example:
`ejs
Analytics Report - <%= new Date().toLocaleDateString() %>
Performance Metrics
<%
const growth = ((metrics.current - metrics.previous) / metrics.previous * 100).toFixed(2);
const status = growth > 0 ? 'š UP' : 'š DOWN';
%>
- Total Revenue: $<%= metrics.current.toLocaleString() %>
- Previous Period: $<%= metrics.previous.toLocaleString() %>
- Growth: <%= status %> <%= Math.abs(growth) %>%
Top Products
<% products.sort((a, b) => b.sales - a.sales).slice(0, 3).forEach((product, index) => { %>
<%= index + 1 %>. <%= product.name.toUpperCase() %>
Sales: $<%= product.sales.toLocaleString() %>
Units: <%= product.units %>
Avg Price: $<%= (product.sales / product.units).toFixed(2) %>
<% }); %>
Summary
<% if (growth > 10) { %>
š Excellent performance! Growth exceeded 10%.
<% } else if (growth > 0) { %>
ā
Positive growth. Keep it up!
<% } else { %>
ā ļø Negative growth. Review strategy.
<% } %>
`Variables:
`json
{
"metrics": {
"current": 125000,
"previous": 98000
},
"products": [
{"name": "Widget Pro", "sales": 45000, "units": 150},
{"name": "Gadget Plus", "sales": 38000, "units": 200},
{"name": "Tool Master", "sales": 42000, "units": 100}
]
}
`Learn more: EJS Documentation
---
š” Use Cases
$3
Generate dynamic prompts for ChatGPT, Claude, GPT-4, and other AI models:
`handlebars
You are a {{role}} assistant specializing in {{domain}}.Task: {{task}}
Context:
{{#each contextItems}}
- {{this}}
{{/each}}
Requirements:
- Tone: {{tone}}
- Length: {{maxWords}} words
- Format: {{format}}
- Target Audience: {{audience}}
Additional Instructions:
{{#if includeExamples}}
Provide at least {{exampleCount}} examples.
{{/if}}
Please provide a comprehensive response following these guidelines.
`$3
Create personalized email campaigns:
`handlebars
Subject: {{#if isPremium}}š Exclusive Offer for {{firstName}}{{else}}Special Offer Inside!{{/if}}Hi {{firstName}},
{{#if isPremium}}
As a valued premium member, we're excited to offer you an exclusive {{discount}}% discount!
{{else}}
We have a special offer just for you!
{{/if}}
{{#each recommendedProducts}}
š¦ {{this.name}}
Regular Price: ${{this.originalPrice}}
{{#if ../isPremium}}Your Price: ${{this.premiumPrice}}{{else}}Sale Price: ${{this.salePrice}}{{/if}}
{{/each}}
Use code: {{promoCode}}
Offer expires: {{expiryDate}}
Best regards,
The {{companyName}} Team
`$3
Generate formatted business reports:
`nunjucks
{{ reportTitle }} - {{ reportDate | date("MMMM DD, YYYY") }}
Executive Summary
Total Revenue: ${{ revenue | formatNumber }}
Total Orders: {{ orderCount }}
Average Order Value: ${{ (revenue / orderCount) | round(2) }}
{% if growthRate > 0 %}
š Revenue Growth: +{{ growthRate }}%
{% else %}
š Revenue Change: {{ growthRate }}%
{% endif %}
Regional Performance
{% for region in regions %}
$3
- Revenue: ${{ region.revenue | formatNumber }}
- Orders: {{ region.orders }}
- Top Product: {{ region.topProduct }}
{% endfor %}Insights
{% for insight in insights %}
- {{ insight }}
{% endfor %}
`$3
Create dynamic API payloads:
`json
{
"query": "{{searchQuery}}",
"filters": {
"category": "{{category}}",
"priceRange": {
"min": {{minPrice}},
"max": {{maxPrice}}
},
"inStock": {{inStock}},
"tags": [{{#each tags}}"{{this}}"{{#unless @last}},{{/unless}}{{/each}}]
},
"sort": {
"field": "{{sortField}}",
"order": "{{sortOrder}}"
},
"pagination": {
"page": {{page}},
"limit": {{pageSize}}
}
}
`$3
Auto-generate technical documentation:
`markdown
API Documentation - {{apiName}} v{{version}}
Endpoints
{{#each endpoints}}
$3
Description: {{this.description}}
Authentication: {{#if this.requiresAuth}}Required{{else}}Not required{{/if}}
Parameters:
{{#each this.parameters}}
-
{{this.name}} ({{this.type}}) - {{this.description}}
{{#if this.required}}Required{{else}}Optional{{/if}}
{{/each}}Example Request:
\
\\{{this.exampleLanguage}}\\Response:
\
\\json\\---
{{/each}}
`$3
Generate social media posts:
`handlebars
{{#if platform}}{{#eq platform "twitter"}}
š {{announcement}}{{#each features}}
ā
{{this}}
{{/each}}
Learn more: {{url}}
#{{hashtag1}} #{{hashtag2}}
{{/eq}}{{/if}}
{{#if platform}}{{#eq platform "linkedin"}}
I'm excited to announce: {{announcement}}
Key features:
{{#each features}}
⢠{{this}}
{{/each}}
This is a game-changer for {{audience}}.
{{url}}
{{/eq}}{{/if}}
`---
āļø Configuration
$3
| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| Templating Engine | Dropdown | Yes | Mustache | Choose the template engine |
| Template | String | Yes | - | The template string with placeholders |
| Variables | JSON | Yes |
{} | Data to populate the template |$3
The Template field automatically updates its placeholder based on the selected engine, showing you the appropriate syntax.
$3
You can use N8N expressions in the Variables field:
`javascript
// Pass all incoming data
={{$json}}// Pass specific fields
={{"name": $json.customerName, "email": $json.email}}
// Combine static and dynamic data
={{"greeting": "Hello", "name": $json.name, "date": $now}}
// Use data from previous nodes
={{"userData": $node["Get User"].json, "orderId": $json.id}}
`$3
The node returns:
`json
{
"text": "The rendered template text",
"metadata": {
"engine": "mustache",
"charCount": 145,
"lineCount": 8,
"timestamp": "2025-11-08T10:30:00.000Z"
}
}
`---
š Best Practices
$3
- Simple substitution? ā Use Mustache
- Need if/else? ā Use Handlebars
- Need filters? ā Use Nunjucks
- Need calculations? ā Use EJS
$3
- ā
DO use Mustache/Handlebars for user-generated content
- ā
DO enable autoescape in Nunjucks
- ā ļø CAREFUL with EJS and untrusted data
- ā DON'T put sensitive data in templates
- ā DON'T use EJS with user input without sanitization
$3
- Keep templates under 10KB for best performance
- Cache frequently used templates upstream
- Use simpler engines (Mustache/Handlebars) when possible
- Process large batches in chunks
$3
`javascript
// Good: Clear, organized template
const template = {{#if premium}}
VIP Content
{{/if}};
// Bad: Messy, hard to read
const template = "Hello {{name}}! {{#if premium}}VIP{{/if}}";
`
Always handle potential errors in your workflow:
1. Use an IF node to check for empty templates
2. Add error handlers for invalid JSON in variables
3. Test with edge cases (empty strings, null values)
4. Monitor the metadata output for issues
---
1. Refresh browser (Cmd+Shift+R or Ctrl+Shift+F5)
2. Check installation:
`bash`
cd ~/.n8n/nodes
ls | grep text-templater
`
3. Restart N8N:
bash`
n8n restart
4. Check N8N logs for errors
1. Check syntax matches selected engine
2. Verify variable names match placeholders exactly
3. Validate JSON in variables field
4. Look at error messages in execution details
1. Ensure JSON is valid (use a JSON validator)
2. Check for typos in variable names
3. Verify N8N expressions are correct: ={{$json.field}}
4. Test with static JSON first
1. Reduce template size (break into smaller chunks)
2. Use a simpler engine (Mustache instead of EJS)
3. Process fewer items per execution
4. Check for infinite loops in templates
| Error | Cause | Solution |
|-------|-------|----------|
| "Invalid JSON" | Malformed variables | Validate JSON syntax |
| "Template syntax error" | Wrong syntax for engine | Check engine-specific docs |
| "Variable not found" | Missing data | Verify variable names |
| "Node not found" | Not installed | Reinstall the node |
---
We welcome contributions! Here's how you can help:
Found a bug? Create an issue with:
- N8N version
- Node version
- Template engine used
- Steps to reproduce
- Expected vs actual behavior
Have an idea? Open a feature request describing:
- The use case
- Proposed solution
- Alternative approaches considered
1. Fork the repository
2. Create a feature branch: git checkout -b feature/amazing-featurenpm run lint:fix
3. Make your changes
4. Add tests if applicable
5. Run linting: git commit -m 'Add amazing feature'
6. Commit: git push origin feature/amazing-feature
7. Push:
8. Open a Pull Request
`bashClone your fork
git clone https://github.com/YOUR-USERNAME/n8n-nodes-text-templater.git
cd n8n-nodes-text-templater
---
š License
This project is licensed under the MIT License - see the LICENSE file for details.
---
š Links
- GitHub Repository: https://github.com/llmx-de/n8n-nodes-text-templater
- npm Package: https://www.npmjs.com/package/n8n-nodes-text-templater
- Issues & Support: https://github.com/llmx-de/n8n-nodes-text-templater/issues
- N8N Documentation: https://docs.n8n.io/integrations/community-nodes/
- LLMX Website: https://llmx.de
---
š Show Your Support
If this node helps your workflow, please:
- ā Star the repository on GitHub
- š¦ Rate the package on npm
- š¦ Share with your network
- š¬ Contribute improvements
---
š·ļø Keywords
n8n n8n-node n8n-community-node workflow-automation template-engine mustache handlebars nunjucks ejs text-templating dynamic-content ai-prompts email-automation report-generation api-integration chatgpt gpt-4 claude workflow automation low-code no-code`---
Made with ā¤ļø by LLMX | Powered by N8N