A complete reference guide to all built-in and custom Liquid filters for transforming your data.
{{ variable | filter_name: argument1, argument2 }}
Filter & Syntax | Description | Example |
---|---|---|
upcase | Converts a string to uppercase. | {{ "hello" | upcase }} → HELLO |
downcase | Converts a string to lowercase. | {{ "HELLO" | downcase }} → hello |
capitalize | Capitalizes the first word of a string. | {{ "hello world" | capitalize }} → Hello world |
truncate: num | Shortens a string to num characters. | {{ "Hello world" | truncate: 8 }} → Hello... |
split: "char" | Splits a string into an array on a character. | {{ "a,b,c" | split: "," }} → ["a","b","c"] |
append: "str" | Adds a string to the end. | {{ "hello" | append: " world" }} → hello world |
prepend: "str" | Adds a string to the beginning. | {{ "world" | prepend: "hello " }} → hello world |
remove: "str" | Removes all occurrences of a substring. | {{ "hello world" | remove: "l" }} → heo word |
replace: "a", "b" | Replaces all occurrences of string “a” with “b”. | {{ "hi hi" | replace: "hi", "bye" }} → bye bye |
escape | Escapes a string for use in HTML. | {{ "<p>text</p>" | escape }} → <p>text</p> |
Filter & Syntax | Description | Example |
---|---|---|
plus: num | Adds a number. | {{ 5 | plus: 3 }} → 8 |
minus: num | Subtracts a number. | {{ 5 | minus: 3 }} → 2 |
times: num | Multiplies by a number. | {{ 5 | times: 3 }} → 15 |
divided_by: num | Divides by a number. | {{ 15 | divided_by: 3 }} → 5 |
round: digits | Rounds to the nearest integer or specified decimal places. | {{ 4.56 | round }} → 5 |
ceil | Rounds up to the nearest integer. | {{ 4.1 | ceil }} → 5 |
floor | Rounds down to the nearest integer. | {{ 4.9 | floor }} → 4 |
Filter & Syntax | Description | Example |
---|---|---|
size | Returns the number of items in an array. | {{ [1,2,3] | size }} → 3 |
first | Returns the first item of an array. | {{ ["a","b"] | first }} → a |
last | Returns the last item of an array. | {{ ["a","b"] | last }} → b |
join: "char" | Joins array elements with a character. | {{ ["a","b"] | join: ", " }} → a, b |
sort: "key" | Sorts an array. Can sort an array of objects by a key. | {{ [3,1,2] | sort }} → [1,2,3] |
uniq | Removes duplicate elements from an array. | {{ [1,2,2,3] | uniq }} → [1,2,3] |
map: "key" | Creates an array of values by extracting a key from objects. | {{ users | map: "name" }} → ["Alice", "Bob"] |
carbon_date
{{ date_string | carbon_date: "output_format" }}
Code | Description | Example |
---|---|---|
Y | Four-digit year | 2025 |
m | Month (01-12) | 12 |
d | Day (01-31) | 25 |
H | Hour (00-23) | 10 |
i | Minute (00-59) | 30 |
s | Second (00-59) | 00 |
F | Full month name | December |
M | Short month name | Dec |
l | Full day of week | Thursday |
D | Short day of week | Thu |
c | ISO 8601 format | 2025-12-25T10:30:00+00:00 |
carbon_condition
true
or false
, making it perfect for use in if
tags.
Syntax: {{ date_string | carbon_condition: "condition_name" }}
Condition | Description |
---|---|
is_today | Is the date today? |
is_tomorrow | Is the date tomorrow? |
is_yesterday | Was the date yesterday? |
is_future | Is the date in the future? |
is_past | Is the date in the past? |
is_weekend | Is the date on a weekend? |
is_weekday | Is the date on a weekday? |
in_7_days | Is the date exactly 7 days from now? |
within_14_days | Is the date between now and 14 days from now? |
before_30_days | Is the date before 30 days from now? |
older_than_90_days | Is the date more than 90 days in the past? |
newer_than_3_days | Is the date within the last 3 days? |
after_5_days | Is the date more than 5 days in the future? |
exactly_1_day | Is the date exactly 1 day from now? (Same as is_tomorrow ) |
in_X_days
, you can use singular or plural (e.g., in_1_day
works too).