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.
{{ user.first_name | upper_case }}
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.
{{ user.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 Casing
Useful for standardizing names if your data is messy (e.g., some names are all caps, some are lowercase).
-
{{ user.city | upcase }}→ NEW YORK -
{{ user.city | downcase }}→ new york -
{{ user.city | capitalize }}→ New York
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 {{ user.first_name | default: 'there' }}!
- If name is "Alex": Hi Alex!
- If name is missing: Hi there!
Math Filters
You can perform basic calculations directly in the template. This is useful for things like showing how much more a user needs to spend to reach a goal.
Spend ${{ 100 | minus: event.cart_total }} more to get free shipping!
Advanced: Aborting Messages
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.
Use the drop_customer_if_null filter to automatically skip
the customer if that specific field is empty.
Here is your code: {{ user.unique_code | drop_customer_if_null: 'Missing Code' }}
If `user.unique_code` is empty, this email will not be sent to this customer, and the failure reason 'Missing Code' will be logged.