# Text Template Engine

Fill text templates with variables and data using various template formats

> Canonical page: https://elysiatools.com/en/tools/text-template

- **Category:** Text Processing

- **Keywords:** text, template, variables, fill, replace, text template

## Overview

The Text Template Engine is a versatile utility designed to automate document generation by injecting dynamic data into predefined text structures using popular syntax formats like Mustache, Handlebars, and ES6.

## Inputs

- **Template Text** (textarea): Enter template with variables...
- **Variables Data (JSON)** (textarea): Enter JSON data: {"name": "John", "age": 30}
- **Template Format** (select)
- **Missing Variable Action** (select)
- **Date Format** (select)
- **Number Format** (select)
- **Escape HTML Output** (checkbox)

## When to use

- Generating personalized emails or reports from structured JSON datasets.
- Standardizing repetitive text output across multiple documents or configurations.
- Converting raw data into formatted strings with specific numeric or date requirements.

## How it works

- Paste your base text containing variables into the template field.
- Provide your data in JSON format, ensuring keys match the variables in your template.
- Select your preferred template syntax and formatting rules for dates and numbers.
- Generate the final text output instantly with all variables replaced by your data.

## Use cases

- Bulk generation of personalized customer notification emails.
- Creating standardized configuration files or code snippets from a central data source.
- Formatting complex financial or analytical reports for consistent presentation.

## Frequently asked questions

### Which template formats are supported?

The tool supports Mustache, Handlebars, ES6 template literals, custom delimiters, and simple bracket-based syntax.

### How does the tool handle missing variables?

You can choose to replace missing variables with an empty string, keep the original syntax, display them in brackets, or replace them with the word 'null'.

### Can I format numbers and dates within the template?

Yes, the tool includes dedicated dropdowns to apply specific date formats like ISO or YYYY-MM-DD and number formats like currency, percentage, or decimal.

### Is it possible to escape HTML in the output?

Yes, you can enable the 'Escape HTML Output' checkbox to ensure special characters are safely encoded for web display.

### What input format is required for the data?

The tool requires a valid JSON object where keys correspond to the variable names used in your template text.

## Related tools

- [Messy Text to Structured Data Workbench](https://elysiatools.com/en/tools/messy-text-to-structured-data-workbench): Infer tables from pasted text, mixed delimiters, key-value lines, or HTML and export CSV, JSON, and Markdown.
- [BOM Character Remover](https://elysiatools.com/en/tools/data-bom-remover): Remove BOM (Byte Order Mark) characters from text and file content. Perfect for cleaning up text files that have encoding issues, fixing CSV imports, and preparing data for processing. Features: - Detect and remove UTF-8 BOM (EF BB BF) - Detect and remove UTF-16 BOM (FE FF or FF FE) - Detect and remove UTF-32 BOM (00 00 FE FF or FF FE 00 00) - Support multiple input formats - Visual BOM character display - Detailed detection report - Support for batch text processing Common Use Cases: - Fix CSV file import errors - Clean up text file encoding issues - Prepare data for JSON parsing - Fix XML parsing problems - Resolve API data encoding conflicts - Standardize text data format
- [TOML-JSON Converter](https://elysiatools.com/en/tools/toml-json-converter): Convert between TOML and JSON formats with support for comments and complex data structures
- [TXT File Merger](https://elysiatools.com/en/tools/txt-merger): Merge multiple text files with various strategies (concatenate, interleave, etc.)
- [Data URI Generator](https://elysiatools.com/en/tools/data-uri-generator): Convert files into Data URIs (Base64 or percent-encoded) for inlining images, fonts, and assets directly into HTML, CSS, or Markdown
- [Text to Excel Converter](https://elysiatools.com/en/tools/text-to-excel): Convert various text formats to Excel with customizable parsing and formatting options
- [Text to JSON Converter](https://elysiatools.com/en/tools/text-to-json): Convert various text formats to JSON with customizable parsing options
- [PDF Receipt / Ticket Generator](https://elysiatools.com/en/tools/pdf-receipt-ticket): Create a thermal-width receipt PDF with bold title and QR code

## Samples

- [Hex/Unicode Encoding Format Samples](https://elysiatools.com/en/samples/text-hex-unicode-formats): Examples of hex (\xXX) and unicode (\uXXXX) escape sequence encoding formats
- [Apache Arrow Samples](https://elysiatools.com/en/samples/arrow): Apache Arrow in-memory columnar format examples for high-performance data processing and analytics
- [Distributed Tracing Samples](https://elysiatools.com/en/samples/distributed-tracing-samples): Comprehensive distributed tracing examples using Jaeger, OpenTelemetry, and other modern observability tools for microservices architecture
- [JWT Samples](https://elysiatools.com/en/samples/jwt-samples): Comprehensive JWT examples from basic token structure to advanced security implementations
