Skip to content

Liquid Filters

Standard Filters

Returns an absolute value of a number e.g. {% raw %}

{{ -17 | abs }} }} #=> 17

{% endraw %}

append a string e.g. {% raw %}

{{ 'foo' | append:'bar' }} #=> 'foobar'

{% endraw %}

capitalize words in the input sentence

rounds a number up to the nearest integer, e.g. {% raw %}

{{ 4.6 | ceil }} #=> 5

{% endraw %}

reformat a date (syntax reference)

returns the given variable unless it is null or the empty string, when it will return the given value, e.g. {% raw %}

{{ undefined_variable | default: "Default value" }} #=> "Default value"

{% endraw %}

{% raw %}

{{ product_price | default: 2.99 }} #=> 2.99

{% endraw %}

{% raw %}

{% assign product_price = 4.99 %}
{{ product_price | default: 4.99 }} #=> 4.99

{% endraw %}

integer division e.g. {% raw %}

{{ 10 | divided_by:3 }} #=> 3

{% endraw %}

convert an input string to lowercase

returns an escaped version of html without affecting existing escaped entities

html escape a string

get the first element of the passed in array

rounds a number down to the nearest integer, e.g. {% raw %}

{{ 4.6 | floor }} #=> 4

{% endraw %}

join elements of the array with certain character between them

get the last element of the passed in array

strips all whitespace from the beginning of a string

map/collect an array on a given property

subtraction e.g. {% raw %}

{{ 4 | minus:2 }} #=> 2

{% endraw %}

remainder, e.g. {% raw %}

{{ 3 | modulo:2 }} #=> 1

{% endraw %}

replace each newline (\n) with html break

addition e.g. {% raw %}

{{ '10' | plus:'1' }} #=> 11

{% endraw %}

prepend a string e.g. {% raw %}

{{ 'bar' | prepend:'foo' }} #=> 'foobar'

{% endraw %}

remove the first occurrence e.g. {% raw %}

{{ 'barbar' | remove_first:'bar' }} #=> 'bar'

{% endraw %}

remove each occurrence e.g. {% raw %}

{{ 'foobarfoobar' | remove:'foo' }} #=> 'barbar'

{% endraw %}

replace the first occurrence e.g. {% raw %}

{{ 'barbar' | replace_first:'bar','foo' }} #=> 'foobar'

{% endraw %}

replace each occurrence e.g. {% raw %}

{{ 'foofoo' | replace:'foo','bar' }} #=> 'barbar'

{% endraw %}

reverses the passed in array

rounds input to the nearest integer or specified number of decimals e.g. {% raw %}

{{ 4.5612 | round: 2 }} #=> 4.56

{% endraw %}

strips all whitespace from the end of a string

return the size of an array or string

slice a string. Takes an offset and length, e.g. {% raw %}

{{ "hello" | slice: -3, 3 }} #=> llo

{% endraw %}

sort elements of the array

split a string on a matching pattern e.g. {% raw %}

{{ "a~b~c" | split:"~" }} #=> ['a','b', 'c']

{% endraw %}

{% raw %}

{% assign beatles = "Usage, Adoption, Retention, Renewal, Revenue Expansion" | split: ", " %}
{% for member in beatles %}
{{ member }}
{% endfor %}
#=>
Usage
Adoption
Retention
Renewal
Revenue Expansion

{% endraw %}

strip html from string

strip all newlines (\n) from string

strips all whitespace from both ends of the string

multiplication e.g

{% raw %}

{{ 5 | times:4 }} #=> 20

{% endraw %}

truncate a string down to x characters. It also accepts a second parameter that will append to the string e.g. {% raw %}

{{ 'foobarfoobar' | truncate: 5, '.' }} #=> 'foob.'

{% endraw %}

truncate a string down to x words

removed duplicate elements from an array, optionally using a given property to test for uniqueness

convert an input string to uppercase

url encode a string