Skip to main content

Modify the formatting of your placeholders with filters

In this article, we will explain how to use Sendinblue Template Language to modify the placeholders in your emails using filters.

What are filters?

Filters change the output of a placeholder. They are used within double curly braces
{{ }} and separated by a pipe character |, e.g. {{ contact.NAME|upper }}. Multiple filters can be chained and the output of one filter is applied to the next. 

To add a filter to a placeholder in an email campaign or template, you must add it manually. In the Drag & Drop Editor (New), you must also write the placeholder manually, as you cannot add a filter to a placeholder that was added using the Personalization option.

Insert a default value


Inserts a default fallback value for when the placeholder value is empty.

Input Output
Hello {{ contact.NAME|default:'there' }}, Hello there,

Format word case


Makes the first character of a placeholder value capitalized and converts the remaining characters to lowercase.

Input Output
{{ contact.MESSAGE|capfirst }} My red car


Returns a titlecased version of the placeholder value. Words will start with uppercase letters, all remaining characters are lowercase.

Input Output
{{ contact.NAME|title }} John Doe


Makes each character of a placeholder value uppercase.

Input Output
{{ contact.NAME|upper }} JOHN DOE


Makes each character of a placeholder value lowercase.

Input Output
{{ contact.NAME|lower }} john doe


Shortens a placeholder value if it is longer than the specified number of characters. Truncated values will end with an ellipsis (…) included in the character count.

Input Output
{{ contact.MANAGER|truncatechars:7 }} Elisab…

Format numbers


Rounds the output of your placeholder's float values to the specified decimal place.

To function correctly, the passed values should be passed as a number, rather than as a string, and the values should not be passed in quotes as “value”.

Input Output
{{ contact.BALANCE|floatformat:2 }} 40.32
{{ contact.BALANCE|floatformat:0 }} 40


Formats numbers depending on the language of the recipient.

Input Output
{{ params.NUMBER|lang_format:"fr" }} 123 456,789
{{ params.NUMBER|lang_format:"en" }} 123,456.789
{{ params.NUMBER|lang_format:"hi" }} 1,23,456.789
{{ params.NUMBER|lang_format:"bn" }} ১,২৩,৪৫৬.৭৮৯
{{ params.NUMBER|lang_format:"fr,%.2f" }} 123 456,79


  • To force 2 decimals, add ,%.2f after the language filter.
  • For French, the thousands separator is a non-break space.

Format date and time

💡 Good to know
- Day and month abbreviations and full names are supported in English only.
- The reference time is "Monday January 2 15:04:05 -0700 MST 2006".
- If a value is not passed, it’s considered to be 0.
- The default timezone (if not passed) is UTC.
- You may use the am/pm keywords.
- The most common ways to define the timezone are: the dedicated keywords (MST, CET, UTC, Asia/Kolkata etc.), or as numeric, +0100 or -0100, to UTC.


Converts your date format (passed as a string) to a standard date format that may be used with other filters.

To pass your current date format as an argument, format the exact date/time of how the reference time would be displayed if it were the value.

Input Output
{{ params.my_date|time_parse:"Monday 02 January 2006" }} Tuesday 11 March 2021

Note: If your string is formatted using RFC3339 you may use the dedicated parser time_parse_rfc3339 without an argument.


Converts a date to a specified format.

You will get a date from a string by using the time_parse filter or the current time by passing the filter date to the placeholder time_now.

Input Output
{{ "14:01 01/06/2018"|time_parse:"15:04 02/01/2006"|date:"Mon Jan 2 15:04:05 2006" }} Fri Jun 1 14:01:00 2018
{{ time_now|date:"Monday, Jan 2, 2006" }} Will print the current day and date in the specified format
{{ time_now|date:"02/01/2006" }}  Will print the current day and date in the specified format
{{ time_now|date:"01" }}

 Will print the current month

{{ time_now|date:"02" }}

 Will print the current day

{{ time_now|date:"2006" }}

 Will print the current year


Adds number of days to a timestamp or date string. It is mandatory to pass all values to this filter in the following order: "year, month, day".

Input Output
{{ time_now|time_add_date:"1,2,3" }} Will print timestamp after adding 1 year, 2 months and 3 days to the current timestamp
{{ "14:01 01/06/2018"|time_parse:"15:04 02/01/2006"|time_add_date: "1,2,3" }}
2019-08-04 14:01:00 +0000 UTC


Converts a timestamp or a date string according to the timezone passed to the filter. It is mandatory to pass a timezone to the filter in the following format: "location/timezone”.

Input Output
{{ time_now|time_in_location:"Europe/Berlin" }} Will print current timestamp in CEST
{{ "14:01 01/06/2018"|time_parse:"15:04 02/01/2006"|time_in_location: "Europe/Berlin" }} 2018-06-01 16:01:00 +0200 CEST


Adds time duration to a timestamp or a date string. It is mandatory to pass at least one value (hour, minute or second) in the filter.

Input Output
{{ time_now|time_add_duration:"1h2m3s" }} Will print timestamp after adding 1 hour, 2 minutes  and 3 seconds to the time value in the current timestamp
{{ time_now|time_add_duration:"30m" }} Will print timestamp after adding 30 minutes to the time value


Converts a time value to Unix timestamp in seconds.

Input Output
{{ time_now|time_unix }} Will print current Unix timestamp in seconds


Converts a time value to Unix timestamp in nanoseconds.

Input Output
{{ time_now|time_unix_nano }} Will print current Unix timestamp in nanoseconds

Other filters


Returns the first item of a sequence, a mapping, or a string.

Input API request Output
{{ params.array|first }} "params" :
"array" : [ 1,2,3,4 ]


Combines the items in an array into a single string using the argument as a separator.

The separator between elements is empty by default. You may define it with the optional first parameter.

Input Output
{{ [1, 2, 3]|join }} 123
{{ [1, 2, 3]|join: '|' }}


Returns the last item of a sequence, a mapping, or a string.

Input Output
{{ [1, 2, 3, 4]|last }} 4


Returns the number of items of a sequence or a mapping, or the length of a string.

Input Output
{{ ['a', 'b', 'c', 'd']|length }} 4


Marks a string as not requiring further HTML escaping prior to output.


API request Output
{{ params.htmltest|safe }} "params" :{HtmlTest: "<p>This is my test sentence.</p>"} This is my test sentence

Note: Without the safe filter, the HTML tag would be displayed as a normal string in the recipient’s email: <p>This is my test sentence</p>.


Extracts a slice of a sequence, a mapping, or a string.

This filter may be configured to:

A Loop through only the first "n" number of elements in an array In both of these cases, remember that elements in an array are assigned a unique position number starting with "0" as the first position (they are "zero-indexed").
B Loop through elements between two specified positions ("n" and "m") in the array
C Loop through elements between two specified elements in an array.  

In each example, consider that your array contains the following: ["a","b","c","d","e","f","g","h"...].


Input Output


{% for product in params.products|slice:':5' %}
{{ - {{ product.price }}
{% endfor %}
Will loop over the first 5 positions (0-4), which are: ["a","b","c","d","e"]
B {% for product in params.products|slice:'2:3' %}
{{ - {{ product.price }}
{% endfor %}
Will loop over positions (2-3), which are: ["c","d"]
C {% for product in params.products|slice:'b:d' %}
{{ - {{ product.price }}
{% endfor %}
Will loop over the specified elements, which are: ["b","c","d"]

base64_encode or decode

Encodes or decodes base 64:

  • base64_decode decodes a string to a []byte
  • base64_encode encodes a []byte to a string
Input Output{{ contact.FIRSTNAME|base64_encode }} (instead of

The base64_encode and decode filters can take an optional encoding parameter:

  • std: normal base64 encoding,
  • raw_std: normal base64 encoding, without the = padding characters,
  • url: URL safe version of base64 encoding, + and / are replaced with - and _ respectively,
  • raw_url: a combination of raw and url, e.g. {{ contact.FIRSTNAME|base64_encode:"raw_url"}}.

Additional resources

Sendinblue Template Language  is based on Pongo2, which is a re-implementation of Django in Go (a programming language).

All supported tags

autoescape, comment, cycle, filter, firstof, for, if, ifchanged, now, set, spaceless, templatetag, with.

All supported filters

escape, safe, escapejs, add, addslashes, capfirst, center, cut, date, default, default_if_none, divisibleby, first, floatformat, get_digit, iriencode, join, last, length, length_is, linebreaks, linebreaksbr, linenumbers, ljust, lower, make_list, phone2numeric, pluralize, random, removetags, rjust, slice, stringformat, striptags, time, title, truncatechars, truncatechars_html, truncatewords, truncatewords_html, upper, urlencode, urlize, urlizetrunc, wordcount, wordwrap, yesno.

All supported filters for hash algorithms

hash_md5, hash_sha256, hash_sha256_224, hash_sha512, hash_sha512_224, hash_sha512_256, hash_sha512_384, hash_sha3_224, hash_sha3_256, hash_sha3_384, hash_sha3_512.

💡 Good to know
If you identify a filter that is not yet supported, please reach out to our customer care team by creating a ticket from your account. If you don't have an account yet, you can contact us here.

⏩ What's next?

🤔 Have a question?

If you have a question, feel free to contact our support team by creating a ticket from your account. If you don't have an account yet, you can contact us here.