Thymeleaf

Default templating language for Spring Boot


title: "Thymeleaf" type: doc version: 1 created: 2026-02-28 author: "Wikipedia contributors" status: active scope: public tags: ["java-enterprise-platform", "template-engines", "java-(programming-language)-libraries", "free-software-programmed-in-java", "software-using-the-apache-license"] description: "Default templating language for Spring Boot" topic_path: "general/java-enterprise-platform" source: "https://en.wikipedia.org/wiki/Thymeleaf" license: "CC BY-SA 4.0" wikipedia_page_id: 0 wikipedia_revision_id: 0

::summary Default templating language for Spring Boot ::

::data[format=table title="Infobox software"]

FieldValue
nameThymeleaf
logoThymeleaf Logo with name small.png
developerDaniel Fernández
latest release version3.1.3
latest release date
operating systemCross-platform
programming languageJava
genreTemplate Engine
standardXML, XHTML, HTML5
licenseApache License 2.0
website
::

| name = Thymeleaf | logo = Thymeleaf Logo with name small.png | screenshot = | caption = | developer = Daniel Fernández | latest release version = 3.1.3 | latest release date = | operating system = Cross-platform | programming language = Java | genre = Template Engine | standard = XML, XHTML, HTML5 | license = Apache License 2.0 | website = Thymeleaf is a Java XML/XHTML/HTML5 template engine that can work both in web (servlet-based) and non-web environments. It is better suited for serving XHTML/HTML5 at the view layer of MVC-based web applications, but it can process any XML file even in offline environments. It provides full Spring Framework integration.

In web applications Thymeleaf aims to be a complete substitute for JavaServer Pages (JSP), and implements the concept of Natural Templates: template files that can be directly opened in browsers and that still display correctly as web pages.

Thymeleaf is open-source software, licensed under the Apache License 2.0.

Features

From the project's website:

  • Java template engine for XML, XHTML and HTML5.
  • Works both in web and non-web (offline) environments. No hard dependency on the Servlet API.
  • Based on modular feature sets called dialects.
    • Dialect features (e.g.: evaluation, iteration, etc.) are applied by linking them to template's tags and/or attributes.
    • Two dialects available out-of-the-box: Standard and SpringStandard (for Spring MVC apps, same syntax as Standard).
    • Developers can extend and create custom dialects.
  • Several template modes:
    • XML: validating against a DTD or not.
    • XHTML 1.0 and 1.1: validating against standard DTDs or not.
    • HTML5: both XML-formed code and legacy-based HTML5. Legacy non-XML code will be automatically cleaned and converted to XML form.
  • Full (and extensible) internationalization support.
  • Configurable, high performance parsed template cache that reduces input/output to the minimum.
  • Automatic DOCTYPE translations –from template DTD to result DTD– for (optional) validation of both template and result code.
  • Extremely extensible: can be used as a template engine framework if needed.
  • Complete documentation including several example applications.

Thymeleaf example

The following example produces an HTML5 table with rows for each item of a List variable called allProducts.

::code[lang=html]

Name Price
Oranges 0.99
::

This piece of code includes:

  • Internationalization expressions: * #{ ... } rh*
  • Variable/model-attribute evaluation expressions: * ${ ... } *
  • Utility functions: * #numbers.formatDecimal( ... ) *

Also, this fragment of (X)HTML code can be perfectly displayed by a browser as a prototype, without being processed at all: it is a natural template.

References

References

  1. "Thymeleaf 3.1: What's new and how to migrate - Thymeleaf".
  2. "Features - Thymeleaf: Java XML/XHTML/HTML5 template engine".

::callout[type=info title="Wikipedia Source"] This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page. ::

java-enterprise-platformtemplate-enginesjava-(programming-language)-librariesfree-software-programmed-in-javasoftware-using-the-apache-license