Glossary of variable filters

Last updated at:

You will learn

Learn about different filters, what they do, and examples of how they should be formatted. Variable filters can be used to adjust and manipulate the data you show in a campaign, flow, or SMS message. For example, the title filter can be used to apply title case formatting to a piece of text pulled in from a customer profile or event data. 

Learn how to use these filters to customize the profile and event data you use in messages to your subscribers. 


Filter Description Examples


Adds a set number to your variable.

If your_variable is 5, {{ your_variable|add:2 }} will render as 7


Encodes a value in Base-64 format. A common use case would be encoding an email address so it can be passed within a UTM parameter. 

{{|base64_encode }}


Supplies a default value to be used if the variable is empty. 

“Hey {{ first_name|default:'friend' }}!” would render like this, given no first name is provided:
Hey friend!


Divides a variable by the number supplied. 

If your variable is 10, {{ your_variable|divide:4 }} will render as 2.5


Escapes a string’s HTML. The specific replacements made are:
< is converted to &lt;
> is converted to &gt;
' (single quote) is converted to &#39;
" (double quote) is converted to &quot;
& is converted to &amp;

Use this filter if your event data passes HTML-encoded data, to allow it to display without extra symbols. 

{{ your_variable|escape }}


Specifies the number of decimal places to display. A common use case is to show a price with two decimal places, regardless of how many digits are supplied. 

If your variable is 5 or 5.0003, {{ your_variable|floatformat:2 }} will render as 5.00


Formats a date variable as a string following this format: Feb. 11, 2016, 4:46 p.m.

{{ your_variable|format_date_string }}


Converts a list to a string, with all list items connected by the string you supply. 

If your variable contains the list ['a', 'b', 'c'], {{ your_variable|join:'//' }} will render as a // b // c .


Converts a list into a string, with proper list punctuation. 

If your variable contains the list ['apple', 'banana', 'orange'], {{ your_variable|list_to_string }} will render as apple, banana and orange


If a provided image is invalid, supplies a blank image, so no error displays.

{{ your_variable|missing_image }}


If a provided product image is blank, supplies a placeholder image. 

{{ your_variable|missing_product_image }}

Placeholder image: 



Searches a list for the index provided. If the list is not indexed, numbers can be used instead (starting with 0)

If your variable is [‘apple','banana','orange'], {{ your_variable|lookup:0 }} will render as apple


Converts a string to all-lowercase

If your variable is HELLO, {{ your_variable|lower }} will render as hello  


Multiplies your variable by the number provided

If your variable is 10, {{ your_variable|multiply:7 }} will render as 70.0


Converts a number to a percentage, with the number of decimal places specified in the argument. If no argument is included, 0 decimals will be shown. 

If your variable is .25, {{ your_variable|percentize }} will render as 25% and {{ your_variable|percentize:2 }} will render as 25.00%


Rounds a number down to the nearest whole number. Optionally, you may specify the number of digits to round down to. 

If your variable is 2.912, {{ your_variable|round_down }} will return 2.0, and {{ your_variable|round_down:2 }} will return 2.91


Rounds a number up to the nearest whole number. Optionally, you may specify the number of digits to round up to. 

If your variable is 2.912, {{ your_variable|round_up }} will return 3.0, and {{ your_variable|round_up:2 }} will return 2.92


Can be applied to a list or string. If applied to a list, it provides the list items specified. If applied to a string, it provides the characters specified. 

If your variable is hello world

{{ your_variable|slice:':5' }} renders as hello

{{ your_variable|slice:'3:8' }} renders as lo wo

{{ your_variable|slice:'8:' }} renders as rld


Splits a string based on a specific character and returns a list.

{{ your_variable|split:',' }}

If your variable contains the string apple, orange, banana, the output will be: ['apple', ' orange', ' banana']


Converts a string to title case.

If your variable is hello world, {{ your_variable|title }} will render as Hello World


Converts a string to uppercase.

If your variable is hello, {{ your_variable|upper }} will render as HELLO


This glossary is not exhaustive; review the full list of Django’s built-in filters

Additional resources

Was this article helpful?
49 out of 82 found this helpful