# template2text: Create Text / HTML from Template and Data

> template2text (Create Text / HTML from Template and Data) is a 1001fx API function in the group Data & JSON: POST https://api.1001fx.com/data/template2text, 2 credits per call. It works as a ready-made module in Make and n8n or as a plain HTTP call.

Creates any text from template and given data. For example, dynamically generate HTML templates with data and logic, making it useful for building dynamic web applications. Based on Handlebars - see https://handlebarsjs.com/ for more details.

- Group: Data & JSON
- Endpoint: `POST https://api.1001fx.com/data/template2text`
- Authentication: header `X-API-KEY: YOURSECRETAPIKEY`
- Content type: application/json
- Credits: 2 credits per call
- Ready-made in: Make and n8n
- Docs: https://1001fx.com/functions/template2text

## Parameters

- `template` (string, required) – Template: Template to be filled in with data. For expressions you can use the following syntaxes: {{ name }} and { { name } }. See handlebars documentation.
- `data` (object, optional) – JSON Input: Data used to fill the template.
- `dataString` (string, optional) – Stringified Data Input: Stringified Data used to fill the template.
- `noEscape` (boolean, optional) – No Escape: Set to true to not HTML escape any content.
- `preventIndentation` (boolean, optional) – Prevent Indentation: By default, an indented partial-call causes the output of the whole partial being indented by the same amount. This can lead to unexpected behavior when the partial writes pre-tags. Setting this option to true will disable the auto-indent feature.

## Example: Data as JSON object

```bash
curl -X POST 'https://api.1001fx.com/data/template2text' \
  -H 'X-API-KEY: YOURSECRETAPIKEY' \
  -H 'Content-Type: application/json' \
  -d '{"template":"{{#each peopleData}}<div class='\''person'\''><h2>{{name}}</h2><p><strong>Age:</strong> {{age}}</p><p><strong>Occupation:</strong> {{occupation}}</p><p><strong>Email:</strong> {{email}}</p></div>{{/each}}","data":{"peopleData":[{"name":"John Smith","age":32,"occupation":"Software Engineer","email":"john.smith@example.com"},{"name":"Jane Doe","age":27,"occupation":"Marketing Manager","email":"jane.doe@example.com"}]},"noEscape":false,"preventIndentation":true}'
```

Answer (HTTP 200):

```json
{
  "result": "<div class='person'><h2>John Smith</h2><p><strong>Age:</strong> 32</p><p><strong>Occupation:</strong> Software Engineer</p><p><strong>Email:</strong> john.smith@example.com</p></div><div class='person'><h2>Jane Doe</h2><p><strong>Age:</strong> 27</p><p><strong>Occupation:</strong> Marketing Manager</p><p><strong>Email:</strong> jane.doe@example.com</p></div>"
}
```
