The Google phone number parser & formatter is very helpful to ensure the same number format for user prodived data. To simplify the use in Spring Boot application with Thymeleaf I created a wrapping TagLib/ExpressionFactory.

The source code is available on GitHub: itds-ch/phonenumber-thymeleaf-taglib


Add dependency

compile "ch.itds.taglib:phonenumber-thymeleaf-taglib:1.0.0"

Register Dialect

import ch.itds.taglib.phonenumber.PhoneNumberDialect; 

public PhoneNumberDialect phoneNumberDialect() {
    return new PhoneNumberDialect();

Format number

<a th:href="|tel:${#phoneNumber.format('044 111 22 33', 'CH', 'E164')}|"
   th:text="${#phoneNumber.format('044 111 22 33', 'CH', 'NATIONAL')}"></a>