Developers · Liquid
Filters: Standard
Last updated 2 November 2026
Use this document to guide you in using standard Liquid filters.
abs
Returns the absolute value of a number.
Input
{{ -17 | abs }}Output
17Input
{{ 4 | abs }}Output
4Input
{{ '-19.86' | abs }}Output
19.86append
Concatenates two strings and returns the concatenated value.
Input
{{ '/my/fancy/url' | append: '.html' }}Output
/my/fancy/url.htmlInput
{% assign filename = '/index.html' %}
{{ 'website.com' | append: filename }}Output
website.com/index.htmlInput
{{ 3 | append: ' stooges' }}Output
3 stoogesat_least
Limits a number to a minimum value.
Input
{{ 4 | at_least: 5 }}Output
5Input
{{ 4 | at_least: 3 }}Output
4at_most
Limits a number to a maximum value.
Input
{{ 4 | at_most: 5 }}Output
4Input
{{ 4 | at_most: 3 }}Output
3capitalize
Makes the first character of a string capitalized.
Input
{{ 'title' | capitalize }}Output
TitleInput
{{ 'my great title' | capitalize }}Output
My great titleceil
Rounds the input up to the nearest whole number. Liquid tries to convert the input to a number before the filter is applied.
Input
{{ 1.2 | ceil }}Output
2Input
{{ 2.0 | ceil }}Output
2Input
{{ 183.357 | ceil }}Output
184Here the input value is a string:
Input
{{ '3.5' | ceil }}Output
4concat
Concatenates (joins together) multiple arrays. The resulting array contains all the items from the input arrays.
Input
{% assign fruits = 'apples, oranges, peaches' | split: ', ' %}
{% assign vegetables = 'carrots, turnips, potatoes' | split: ', ' %}
{% assign everything = fruits | concat: vegetables %}
{% for item in everything %}
- {{ item }}
{% endfor %}Output
- apples
- oranges
- peaches
- carrots
- turnips
- potatoesYou can string together
Input
{% assign furniture = 'chairs, tables, shelves' | split: ', ' %}
{% assign everything = fruits | concat: vegetables | concat: furniture %}
{% for item in everything %}
- {{ item }}
{% endfor %}Output
- apples
- oranges
- peaches
- carrots
- turnips
- potatoes
- chairs
- tables
- shelvesdate
Converts a timestamp into another date format. The format for this syntax is the same as
Input
{{ article.published_at | date: '%a, %b %d, %y' }}Output
Fri, Jul 17, 15Input
{{ article.published_at | date: '%Y' }}Output
2015Input
{{ 'March 14, 2016' | date: '%b %d, %y' }}Output
Mar 14, 16To get the current time, pass the special word
Input
This page was last updated at {{ 'now' | date: '%Y-%m-%d %H:%M' }}.Output
This page was last updated at 2022-08-09 04:04.Note that the value will be the current time of when the page was last generated from the template, not when the page is presented to a user if caching or static site generation is involved.
default
Allows you to specify a fallback in case a value doesn’t exist.
Input
{{ product_price | default: 2.99 }}Output
2.99In this example,
Input
{% assign product_price = 4.99 %}
{{ product_price | default: 2.99 }}Output
4.99In this example,
Input
{% assign product_price = '' %}
{{ product_price | default: 2.99 }}Output
2.99To allow variables to return
Input
{{ settings.flag | default: true, allow_false: true }}Output
<!-- If settings.flag is false -->
falsedivided_by
Divides a number by the specified number. The result is rounded down to the nearest integer (that is, the floor) if the divisor is an integer.
Input
{{ 16 | divided_by: 4 }}Output
4Input
{{ 5 | divided_by: 3 }}Output
1Controlling rounding
For example, here the divisor is an integer:
Input
{{ 20 | divided_by: 7 }}Output
2Here it is a float:
Input
{{ 20 | divided_by: 7.0 }}Output
2.857142857142857Changing variable types
You might want to use a variable as a divisor, in which case you can’t simply add .0 to convert it to a float. In these cases, you can assign a version of your variable converted to a float using the
In this example, you’re dividing by a variable that contains an integer, so you get an integer:
Input
{% assign my_integer = 7 %}
{{ 20 | divided_by: my_integer }}Output
2Here, you multiply the variable by
Input
{% assign my_integer = 7 %}
{% assign my_float = my_integer | times: 1.0 %}
{{ 20 | divided_by: my_float }}Output
2.857142857142857downcase
Makes each character in a string lowercase. It has no effect on strings that are already all lowercase.
Input
{{ 'Parker Moore' | downcase }}Output
parker mooreInput
{{ 'apple' | downcase }}Output
appleescape
Escapes a string for HTML. It replaces characters such as <, >, & and quotes with HTML entities. It does not change strings that have nothing to escape. To encode a value for a URL, use url_encode.
Input
{{ '<p>Have you read James & the Giant Peach?</p>' | escape }}Output
<p>Have you read James & the Giant Peach?</p>Input
{{ 'Nikola Tesla' | escape }}Output
Nikola Teslafirst
Input
{% assign my_array = 'apples, oranges, peaches, plums' | split: ', ' %} {{ my_array.first }}Output
applesInput
{% assign my_array = 'zebra, octopus, giraffe, tiger' | split: ', ' %}
{{ my_array.first }}Output
zebrafloor
Rounds a number down to the nearest whole number. Liquid tries to convert the input to a number before the filter is applied.
Input
{{ 1.2 | floor }}Output
1Input
{{ 2.0 | floor }}Output
2Input
{{ 183.357 | floor }}Output
183Here the input value is a string:
Input
{{ '3.5' | floor }}Output
3join
Combines the items in an array into a single string using the argument as a separator.
Input
{% assign beatles = 'John, Paul, George, Ringo' | split: ', ' %}
{{ beatles | join: ' and ' }}Output
John and Paul and George and Ringolast
Returns the last item of an array.
Input
{% assign my_array = 'apples, oranges, peaches, plums' | split: ', ' %}
{{ my_array.last }}Output
plumsInput
{% assign my_array = 'zebra, octopus, giraffe, tiger' | split: ', ' %}
{{ my_array.last }}Output
tigerlstrip
Removes all whitespaces (tabs, spaces, and newlines) from the beginning of a string. The filter does not affect spaces between words.
Input
A sentence before. {{ ' So much room for activities! ' | lstrip }} A sentence after.Output
A sentence before. So much room for activities! A sentence after.map
Important
Insites overrides the map filter, so it does not work in the standard way. Visit the reference for the Insites map filter to learn more.
minus
Subtracts a number from another number.
Input
{{ 4 | minus: 2 }}Output
2Input
{{ 16 | minus: 4 }}Output
12Input
{{ 183.357 | minus: 12 }}Output
171.357modulo
Returns the remainder of a division operation.
Input
{{ 3 | modulo: 2 }}Output
1Input
{{ 24 | modulo: 7 }}Output
3Input
{{ 183.357 | modulo: 12 }}Output
3.357newline_to_br
Replaces every newline
Input
{% capture string_with_newlines %}
Hello
there
{% endcapture %}
{{ string_with_newlines | newline_to_br }}Output
Hello
thereplus
Adds a number to another number.
Input
{{ 4 | plus: 2 }}Output
6Input
{{ 16 | plus: 4 }}Output
20Input
{{ 183.357 | plus: 12 }}Output
195.357prepend
Adds the specified string to the beginning of another string.
Input
{{ 'apples, oranges, and bananas' | prepend: 'Some fruit: ' }}Output
Some fruit: apples, oranges, and bananasYou can also prepend variables:
Input
{% assign url = 'example.com' %}
{{ '/index.html' | prepend: url }}Output
example.com/index.htmlremove
Removes every occurrence of the specified substring from a string.
Input
{{ 'I strained to see the train through the rain' | remove: 'rain' }}Output
I sted to see the t through theremove_first
Removes only the first occurrence of the specified substring from a string.
Input
{{ 'I strained to see the train through the rain' | remove_first: 'rain' }}Output
I sted to see the train through the rainreplace
Replaces every occurrence of an argument in a string with the second argument.
Input
{{ 'Take my protein pills and put my helmet on' | replace: 'my', 'your' }}Output
Take your protein pills and put your helmet onreplace_first
Replaces only the first occurrence of the first argument in a string with the second argument.
Input
{% assign my_string = 'Take my protein pills and put my helmet on' %}
{{ my_string | replace_first: 'my', 'your' }}Output
Take your protein pills and put my helmet onreverse
Reverses the order of the items in an array.
Input
{% assign my_array = 'apples, oranges, peaches, plums' | split: ', ' %}
{{ my_array | reverse | join: ', ' }}Output
plums, peaches, oranges, applesInput
{{ 'Ground control to Major Tom.' | split: '' | reverse | join: '' }}Output
.moT rojaM ot lortnoc dnuorGround
Rounds an input number to the nearest
Input
{{ 1.2 | round }}Output
1Input
{{ 2.7 | round }}Output
3Input
{{ 183.357 | round: 2 }}Output
183.36rstrip
Removes all whitespace (tabs, spaces, and newlines) from the right side of a string.
Input
A sentence before. {{ ' So much room for activities! ' | rstrip }} A sentence after.Output
A sentence before. So much room for activities! A sentence after.size
Returns the number of characters in a string, the number of items in an array, or the number of bytes needed to store the integer in memory. You can also use
Input
{{ 'Ground control to Major Tom.' | size }}Output
28Input
{% assign my_array = 'apples, oranges, peaches, plums' | split: ', ' %}
{{ my_array | size }}Output
4Using dot notation:
{% if my_array.size > 10 %}
This array has more than 10 items.
{% endif %}slice
Returns a substring of 1 character beginning at the index specified by the argument passed in. An optional second argument specifies the length of the substring to be returned.
String indices are numbered starting from 0.
Input
{{ 'Liquid' | slice: 0 }}Output
LInput
{{ 'Liquid' | slice: 2 }}Output
qInput
{{ 'Liquid' | slice: 2, 5 }}Output
quidIf the first parameter is a negative number, the indices are counted from the end of the string:
Input
{{ 'Liquid' | slice: -3, 2 }}Output
uisort
Sorts items in an array by a property of an item in the array. The order of the sorted array is case-sensitive, meaning all capitalized strings will come before any lowercase strings.
Input
{% assign my_array = 'zebra, octopus, giraffe, Sally Snake' | split: ', ' %}
{{ my_array | sort | join: ', ' }}Output
Sally Snake, giraffe, octopus, zebrasort_natural
Sorts items in an array by a property of an item in the array. The order of the sorted array is case-insensitive.
Input
{% assign my_array = 'zebra, octopus, giraffe, Sally Snake' | split: ', ' %}
{{ my_array | sort_natural | join: ', ' }}Output
giraffe, octopus, Sally Snake, zebrasplit
Divides an input string into an array using the argument as a separator.
Input
{% assign beatles = 'John, Paul, George, Ringo' | split: ', ' %}
{% for member in beatles %}
{{ member }}
{% endfor %}Output
John
Paul
George
Ringostrip
Removes all whitespace (tabs, spaces, and newlines) from both the left and right sides of a string. It does not affect spaces between words.
Input
A sentence before. {{ ' So much room for activities! ' | strip }} A sentence after.Output
A sentence before. So much room for activities! A sentence after.strip_html
Removes any HTML tags from a string.
Input
{{ 'Have <em>you</em> read <strong>Ulysses</strong>?' | strip_html }}Output
Have you read Ulysses?strip_newlines
Removes any newline characters (line breaks) from a string.
Input
{% capture string_with_newlines %}
Hello
there
{% endcapture %}
{{ string_with_newlines | strip_newlines }}Output
Hellotheretimes
Multiplies a number by another number.
Input
{{ 3 | times: 2 }}Output
6Input
{{ 24 | times: 7 }}Output
168Input
{{ 183.357 | times: 12 }}Output
2200.284truncate
Input
{{ 'Ground control to Major Tom.' | truncate: 20 }}Output
Ground control to...Custom ellipsis
The length of the second parameter counts against the number of characters specified by the first parameter.
For example, if you want to truncate a string to exactly 10 characters, and use a 3-character ellipsis, use 13 for the first parameter of
Input
{{ 'Ground control to Major Tom.' | truncate: 25, ', and so on' }}Output
Ground control, and so onNo ellipsis
You can truncate to the exact number of characters specified by the first parameter and show no trailing characters by passing a blank string as the second parameter:
Input
{{ 'Ground control to Major Tom.' | truncate: 20, '' }}Output
Ground control to Matruncatewords
Shortens a string down to the number of words passed as the argument. If the specified number of words is less than the number of words in the string, an ellipsis (…) is appended to the string.
Input
{{ 'Ground control to Major Tom.' | truncatewords: 3 }}Output
Ground control to...Custom ellipsis
Input
{{ 'Ground control to Major Tom.' | truncatewords: 3, '--' }}Output
Ground control to--No ellipsis
You can avoid showing trailing characters by passing a blank string as the second parameter:
Input
{{ 'Ground control to Major Tom.' | truncatewords: 3, '' }}Output
Ground control touniq
Removes any duplicate elements in an array.
Input
{% assign my_array = 'ants, bugs, bees, bugs, ants' | split: ', ' %}
{{ my_array | uniq | join: ', ' }}Output
ants, bugs, beesupcase
Makes each character in a string uppercase. It has no effect on strings that are already all uppercase.
Input
{{ 'Parker Moore' | upcase }}Output
PARKER MOOREInput
{{ 'TESLA' | upcase }}Output
TESLAurl_decode
Decodes a string that has been encoded as a URL or by
Input
{{ '%27Stop%21%27+said+Fred' | url_decode }}Output
'Stop!' said Fredurl_encode
Converts any URL-unsafe characters in a string into per cent-encoded characters.
Input
{{ '[email protected]' | url_encode }}Output
john%40liquid.comInput
{{ 'Nikola Tesla' | url_encode }}Output
Nikola+Teslawhere
Creates an array comprising objects with a specified property value or any
For example, suppose you have a list of products and want to display kitchen products separately. By employing
Input
All products:
{% for product in products %}
- {{ product.title }}
{% endfor %}
{% assign kitchen_products = products | where: 'type', 'kitchen' %}
Kitchen products:
{% for product in kitchen_products %}
- {{ product.title }}
{% endfor %}Output
All products:
- Vacuum
- Spatula
- Television
- Garlic press
Kitchen products:
- Spatula
- Garlic pressConsider instead, a scenario where you have a list of products, and your objective is to display only those available for purchase. In this case, you can employ
Input
All products:
{% for product in products %}
- {{ product.title }}
{% endfor %}
{% assign available_products = products | where: 'available' %}
Available products:
{% for product in available_products %}
- {{ product.title }}
{% endfor %}Output
All products:
- Coffee mug
- Limited edition sneakers
- Boring sneakers
Available products:
- Coffee mug
- Boring sneakersThe
Input
{% assign new_shirt = products | where: 'type', 'shirt' | first %}
Featured product: {{ new_shirt.title }}Output
Featured product: Hawaiian print sweater vestTry it
Edit the input and press Run. The example runs on this site, read-only.