Template renderer
Fill a Mustache-style template with JSON data: {{name}} values, {{#list}} loops and {{^empty}} fallbacks.
Input
Result
Fill in the input and press Run.
Your input is processed in memory and then discarded. It is not stored or logged. Even so, don't paste live passwords or keys into any online tool.
Use it from code or an agent
curl -s https://setget.net/v1/tools/template-render \
-H 'Content-Type: application/json' \
-d '{"input":{"template":"Hello {{name}}!\n{{#items}}\n- {{title}} ({{price}})\n{{/items}}\n{{^items}}\nNothing here.\n{{/items}}","data":{"name":"Sam & Co","items":[{"title":"Tea","price":3},{"title":"Cake","price":4.5}]}}}'
import json, urllib.request
body = {'input': {'template': 'Hello {{name}}!\n{{#items}}\n- {{title}} ({{price}})\n{{/items}}\n{{^items}}\nNothing here.\n{{/items}}', 'data': {'name': 'Sam & Co', 'items': [{'title': 'Tea', 'price': 3}, {'title': 'Cake', 'price': 4.5}]}}}
request = urllib.request.Request("https://setget.net/v1/tools/template-render", json.dumps(body).encode(),
{"Content-Type": "application/json"})
print(json.load(urllib.request.urlopen(request))["result"])
const response = await fetch("https://setget.net/v1/tools/template-render", {
method: "POST",
headers: {"Content-Type": "application/json"},
body: JSON.stringify({"input":{"template":"Hello {{name}}!\n{{#items}}\n- {{title}} ({{price}})\n{{/items}}\n{{^items}}\nNothing here.\n{{/items}}","data":{"name":"Sam & Co","items":[{"title":"Tea","price":3},{"title":"Cake","price":4.5}]}}}),
});
console.log((await response.json()).result);
Tool: run_tool
Arguments:
{
"slug": "template-render",
"input": {
"template": "Hello {{name}}!\n{{#items}}\n- {{title}} ({{price}})\n{{/items}}\n{{^items}}\nNothing here.\n{{/items}}",
"data": {
"name": "Sam & Co",
"items": [
{
"title": "Tea",
"price": 3
},
{
"title": "Cake",
"price": 4.5
}
]
}
}
}
{
"input": {
"template": "Hello {{name}}!\n{{#items}}\n- {{title}} ({{price}})\n{{/items}}\n{{^items}}\nNothing here.\n{{/items}}",
"data": {
"name": "Sam & Co",
"items": [
{
"title": "Tea",
"price": 3
},
{
"title": "Cake",
"price": 4.5
}
]
}
}
}
Endpoint: POST /v1/tools/template-render. Over MCP: run_tool with slug: "template-render".
Machine-readable: input schema, Markdown. Connect an agent.
Inputs
| Name | Type | Required | What it does |
|---|---|---|---|
template |
string | yes | The template text. |
data |
json | yes | The values to fill in, as a JSON object. |
escape |
boolean | no | HTML-escape {{name}} values. {{{name}}} is never escaped. Default: true. |
Examples
Input
{
"template": "Hello {{name}}!\n{{#items}}\n- {{title}} ({{price}})\n{{/items}}\n{{^items}}\nNothing here.\n{{/items}}",
"data": {
"name": "Sam & Co",
"items": [
{
"title": "Tea",
"price": 3
},
{
"title": "Cake",
"price": 4.5
}
]
}
}Result
{
"text": "Hello Sam & Co!\n- Tea (3)\n- Cake (4.5)\n"
}Dotted names, raw output and a comment
Input
{
"template": "{{user.name}} wrote {{{html}}}{{! not shown }}",
"data": {
"user": {
"name": "Ada"
},
"html": "<b>3</b>"
}
}Result
{
"text": "Ada wrote <b>3</b>"
}A list of plain values
Input
{
"template": "{{#tags}}[{{.}}]{{/tags}}",
"data": {
"tags": [
"a",
"b"
]
}
}Result
{
"text": "[a][b]"
}Questions
- Which Mustache features work?
- Variables, {{{raw}}} and {{&raw}} output, dotted names, sections over lists and true values, inverted sections and comments. Partials, lambdas and custom delimiters are not supported.
- What counts as false for a section?
- false, null, 0, empty text, an empty list, an empty object and a missing name. {{^name}} shows its content in exactly those cases.
- What happens when a name is missing from the data?
- Nothing is printed for it. No error is raised.
- Why did "&" turn into "&"?
- Values are HTML-escaped by default. Set escape to false for plain text, or use {{{name}}} for one value.
Related tools
- Find and replaceReplace every occurrence of a word or phrase in text, exactly as typed, with a count of the changes.
find-replace - JSON formatterPretty-print JSON with your choice of indentation, optionally sorting keys.
json-format - Escape and unescape textEscape or unescape text for HTML, URLs, JSON strings, shell commands, regular expressions and CSV fields.
escape-unescape - Apply a patchApply a unified diff to a text and get the patched result, with clear errors when a hunk does not fit.
patch-apply - Case converterConvert text between lower, UPPER, Title, Sentence, camelCase, PascalCase, snake_case, kebab-case and more.
case-convert - Extract emails and URLsPull every email address and web link out of a text, and optionally IPv4 addresses and hashtags.
extract-emails-urls