What is the FTL file format?
.ftl is a FreeMarker Template Language file - a plain-text template processed by the Apache FreeMarker Java template engine. FreeMarker runs on the JVM and merges static output content (HTML, XML, plain text, SQL, source code, emails) with FTL directives and expressions to produce final text output server-side.
A .ftl file mixes three kinds of syntax: directives such as <#if>, <#list>, <#include>, <#macro>, and <#assign>; interpolations written as ${expression}; and FTL comments in the form <#-- comment -->. Everything outside these constructs is passed through unchanged to the output.
An optional <#ftl> header directive at the top of the file can declare the file encoding, output format, auto-escaping rules, and whitespace handling. Without it, FreeMarker applies the encoding and settings configured globally in the calling Java application.
Two specialised variants exist alongside .ftl: .ftlh triggers HTML auto-escaping and .ftlx triggers XML auto-escaping, both introduced in FreeMarker 2.3.24. These reduce cross-site scripting risk without requiring explicit escaping calls in every template.
FreeMarker is widely used in Java web frameworks such as Spring MVC, Apache Struts, and Play Framework, as well as code-generation pipelines and document templating systems. The project moved to the Apache Software Foundation in 2015; the current release is FreeMarker 2.3.34 (2024). VS Code and IntelliJ IDEA both support FTL syntax highlighting via plugins.
Security & safety
RISK: LOWFTL templates are plain text files - safe to open in any text editor. Templates run server-side on the JVM; there is no client-side execution. Malicious templates could potentially execute harmful FreeMarker directives (e.g., <#assign exec="freemarker.template.utility.Execute"?new()>) if template rendering runs with insecure configuration - this is a server-side server misconfiguration issue (Server-Side Template Injection / SSTI), not a risk to end users opening the file.
Format details
in a nutshellPrograms that open FTL files
Technical details
deep spec| Template syntax style | Directive-based: `<#tag>` directives + `${expression}` interpolations mixed into static content |
| Default encoding | UTF-8 default; can be overridden via the encoding attribute in the optional `<#ftl>` header directive at file top |
| Execution environment | Java Virtual Machine (JVM); processed server-side by the FreeMarker library |
| Output format | Any text format - HTML, XML, plain text, SQL, source code, email bodies |
| Directive categories | Flow control (`<#if>`, `<#list>`), assignment (`<#assign>`, `<#local>`), definition (`<#macro>`, `<#function>`), inclusion (`<#include>`, `<#import>`) |
| Interpolation syntax | `${expression}` (string/number); `#{number}` supported as legacy numeric interpolation |
| Comment syntax | `<#-- comment -->` - stripped entirely from rendered output |
| Header directive | Optional `<#ftl>` at file top; sets encoding, output_format, auto_esc, strip_whitespace, attributes |
| Auto-escaping variants | `.ftlh` (HTML auto-escape) and `.ftlx` (XML auto-escape) - introduced FreeMarker 2.3.24 |
| Data model access | Java objects passed as a map from the calling application; templates read but cannot modify the model |
| Whitespace control | Configurable `strip_whitespace`; fine-grained control with `<#t>`, `<#lt>`, `<#rt>` directives per line |
| Template reuse | `<#include>` for literal inclusion; `<#import>` for namespace-scoped macro/function libraries |
| Typical file size | 1 KB - 200 KB per template file |
| Released | circa 2002 (FreeMarker first release) |
| Latest version | FreeMarker 2.3.34 (2024); hosted at Apache |
| Open standard | Yes · royalty-free |
| Specification | freemarker.apache.org |
FTL conversions
Community Q&A
asked by usersNo questions yet - be the first to ask about FTL files.