Raw data from your database is rarely formatted exactly how you want it to look in a marketing message. Filters are the tool you use to clean up, format, and transform that data before the customer sees it.
How Filters Work
Filters are used inside Output Tags {{ }}. You apply a filter by adding a pipe character | followed by the filter name.
{{ customer.first_name | upcase }}
Input: "john" → Result: "JOHN"
Essential Filters
Date Formatting
Dates in your database often look technical (e.g., 2023-12-25). The date_format filter turns them into human-readable text.
{{ customer.DOB | date_format: "d MMM yyyy" }}
Result: 25 Dec 1990
You can also manipulate dates, such as adding days to a timestamp:
{{ current_date() | add_days: 10 }}
Text Filters
Useful for standardizing names if your data is messy (e.g., some names are all caps, some are lowercase).
{{ customer.city | upcase }}→ NEW YORK{{ customer.city | downcase }}→ new york{{ customer.city | capitalize }}→ New York
Use append to add text to the end of a value. This is handy for building URLs or adding units to a value.
{{ customer.city | append: ', UK' }}
Input: "London" → Result: London, UK
Default Values (Handling Missing Data)
This is one of the most important filters. If a customer attribute is empty (null), Liquid will print nothing. The default filter allows you to set a fallback value.
Hi {{ customer.first_name | default: 'there' }}!
- If name is "Alex": Hi Alex!
- If name is missing: Hi there!
Dropping Customers with Missing Data
Sometimes a fallback value isn't enough. If a critical piece of data is missing (like a unique promo code), you might prefer not to send the message at all rather than send broken content.
The drop_customer_if_null filter removes the customer from the send when the required data is missing.
{{ customer.first_name | drop_customer_if_null: 'missing name' }}
Here is your code: {{ customer.unique_code | drop_customer_if_null: 'Missing Code' }}
If customer.unique_code is empty, this email will not be sent to this customer.
Always include a reason string. The reason is what appears in the logs when you are diagnosing why a customer was dropped, so make it specific enough to identify the field.
Choosing between the two: use default when a fallback value keeps the message intact. Use drop_customer_if_null when there is no acceptable version of the message without the data.
Math Filters
You can perform basic calculations directly in the template. This is useful for things like showing how much more a customer needs to spend to reach a goal.
Spend ${{ 100 | minus: event.cart_total }} more to get free shipping!
The round filter rounds a number, optionally to a set number of decimal places. It works directly on a value returned from a Data Connection.
{{ value | round }}
{{ value | round: 2 }}