Liquid Markup Filters
  • 04 Apr 2025
  • 2 minute read
  • Dark
    Light
  • PDF

Liquid Markup Filters

  • Dark
    Light
  • PDF

Article summary

In Liquid markup, filters let you transform data before it’s displayed.

This can be useful for modifying the returned value of merge fields or exports, without making adjustments to the underlying query.

Liquid provides a number of standard filter keywords, which we describe in this article.

How Liquid markup filters work

Add filters to text or a Slate query export you want to modify:

  • In a Liquid markup object {{ }}, place some text, or a query export’s name: {{"Hello world"}}

  • Add a pipe delimiter after that content: {{"Hello World | }}

  • Add the filter keyword after the pipe delimiter: {{"Hello World | upcase }}

The filter takes that text or export and transforms it accordingly: HELLO WORLD

Examples

Following the previous example, say you have an export, such as {{academic-intererests}}, that you want to be all lowercase.

You can use downcase:

{{academic-interests | downcase}}

Which renders the value of academic-interests (say, Biology) as:

biology

Chaining filters

You can chain filters together to perform several actions in a row on the same export.

Filters work from left to right: each subsequent filter processes the output rendered by the previous one.

In this example, we take the value of the academic-interest export and render it in all lowercase with downcase. Then, the lowercase academic interest is shortened by truncate to the specified 10 characters:

{{academic-interests | downcase | truncate: 10}}

So, a program like Environmental Sciences would display as environmen.

Standard Liquid filters

The following are standard filters that can operate on Slate exports and plain text:

Filter

Function

Example

date

Formats a date

{{form-date | date: 'MMMM d, yyyy' }}

divided_by

Divides two numbers

{{registration_limit | divided_by: registrants }}

downcase

Sets all letters to lowercase

{{first | downcase }}

first

Returns first element of an array

{{academic_interests | first }}

last

Returns last element of an array

{{academic_interests | last }}

map

Returns only specified elements in an array

{{scholarships | map: 'names'}}

minus

Subtracts two numbers

{{registration_limit | minus: registrants }}

modulo

Returns the remainder after division

{{4 | modulo: 2 }}

plus

Adds two numbers

{{registrants | plus: waitlist }}

replace_first

Replaces first occurrence of first parameter with the second parameter

{{sisID | replace_first:'Slate-', '' }}

size

Returns number of elements in an array, or number of characters in a string

{{academic_interests | size}}

{{academic_interests.size}}

slice

Extracts a substring from a string, starting from first parameter’s position (starting from 0) and through optional second parameter’s

{{ sports | slice: 3,4}}

snippet

Lets you ass in a value and output a content block

{{ program | snippet: "program_long_description" }}

split

Splits string into an array on a specified delimiter

{{ academic_interests | split: "|" }}

strip_html

Removes HTML tags from a string

{{ academic_interests | strip_html }}

times

Multiples two numbers

{{courses | times: 550 }}

truncate

Specify a maximum string length

{{academic-interest | truncate: 5}}

uniq

Removes duplicate values in an array

{{ academic_interests_array | uniq }}

upcase

Sets all letters to uppercase

{{ first | upcase }}

📖 Further reading: See the Shopify documentation on Liquid markup filters.


Was this article helpful?