Liquid Filters
On this page
Filters transform a value on its way into the page: formatting text, reshaping a collection, doing arithmetic. They are applied with a pipe, and can be chained.
```liquid
{{ product.name | upcase }} {{ products | pluck: “name” | json }} ```
Each filter below links to its own article with the full signature and worked examples. To read the whole set on one page instead, see the Liquid filters reference.
Collections
depaginate— Turns off the protective enforced pagination for large collections. Useful when needing to apply other filters to the paginated collection, egwhere. Will trigger a full fetch of the entire collection when used, and could cause performance issues if the data set is large. Use carefullygroup_by— Groups an list of objects by a given propertyjson— Converts the collection to JSONpaginate— Gets the first page of a Paginated collection with the supplied sizepluck— Plucks all values for a given property from an listsample— Returns a random sample in random order of all the values for a given collectionserialize— Serializes the collection as a JSON stringsum— Sums all items in an listtry— Tries to call the supplied attribute against the supplied object. Use this when you know the property may or may not exist on the object as a way to indicate that it’s expected and ok for it not to exist
Lists
compact— Removes any nil values from an listconcat— Concatenates (joins together) multiple lists. The resulting list contains all the items from the input listscontains— Returns true if the list contains the supplied itemdifference— Returns the difference of two listsexcept— Returns all items in the list where the supplied property does not equal the supplied valuefirst— Returns the first item of an listinsert— Inserts an item into an list at the supplied indexintersection— Returns the intersection of two listsjoin— Combines the items in an list into a single string using the argument as a separatorlast— Returns the last item of an listmap— Creates an list of values by extracting the values of a named property from another objectonly— Returns all items in the list where the supplied property equals one of the supplied valuespop— Removes the last item from an listpush— Adds an item to the end of an listreverse— Reverses the order of the items in an list.reversecannot reverse a stringshift— Removes the first item from an listsize— Returns the number of characters in a string or the number of items in an listsort— Sorts items in an list in case-sensitive ordersort_natural— Sorts items in an list in case-insensitive orderunion— Returns the union of two listsuniq— Removes any duplicate items in an listunshift— Adds an item to the beginning of an listwhere— Creates an list including only the objects with a given property value, or any truthy value by default
Maps
collect_keys— Plucks a set of values from a list of mapskeys— Returns a list of the keys of a Mapmerge— Merges two maps togetherrename_keys— Renames keys in a mapset_key— Sets a key in a map to a valueunset_key— Removes a key from a map
Numbers
abs— Returns the absolute value of a numberat_least— Limits a number to a minimum valueat_most— Limits a number to a maximum valueceil— Rounds an input up to the nearest whole number. Liquid tries to convert the input to a number before the filter is applieddivided_by— Divides a number by another numberfloor— Rounds an input down to the nearest whole number. Liquid tries to convert the input to a number before the filter is appliedminus— Subtracts a number from another numbermodulo— Returns the remainder of a division operationmoney— Formats the input as money in the default currencynumber— Formats the input as a number according to the localeplus— Adds a number to another numberpoints— Formats the input as account pointsround— Rounds a number to the nearest integer or, if a number is passed as an argument, to that number of decimal placestimes— Multiplies a number by another number
Text
append— Adds the specified string to the end of another stringcapitalize— Makes the first character of a string capitalized and converts the remaining characters to lowercasedeserialize— Deserializes a JSON stringdowncase— Makes each character in a string lowercase. It has no effect on strings which are already all lowercaseescape— Escapes a string by replacing characters with escape sequences (so that the string can be used in a URL, for example). It doesn’t change strings that don’t have anything to escapeescape_once— Escapes a string without changing existing escaped entities. It doesn’t change strings that don’t have anything to escapehmac— Converts a string into an encrypted hash using a hash message authentication code (HMAC)j— Escapes carriage returns and single and double quotes for JavaScript segmentslstrip— Removes all whitespace (tabs, spaces, and newlines) from the left side of a string. It does not affect spaces between wordsmarkdown— Converts markdown text to HTML using GitHub-Flavored Markdown (GFM)newline_to_br— Inserts an HTML line break in front of each newline in a stringparameterize— Converts a string to parameter formatprepend— Adds the specified string to the beginning of another stringremove— Removes every occurrence of the specified substring from a stringremove_first— Removes only the first occurrence of the specified substring from a stringreplace— Replaces every occurrence of the first argument in a string with the second argumentreplace_first— Replaces only the first occurrence of the first argument in a string with the second argumentrstrip— Removes all whitespace (tabs, spaces, and newlines) from the right side of a string. It does not affect spaces between wordssplit— Splits a string into an list using the argument as a separator.splitis commonly used to convert comma-separated items from a string to an liststrip— Removes all whitespace (tabs, spaces, and newlines) from both the left and right sides of a string. It does not affect spaces between wordsstrip_html— Removes all whitespace (tabs, spaces, and newlines) from both the left and right sides of a string. It does not affect spaces between wordsstrip_newlines— Removes any newline characters (line breaks) from a stringtruncate— Shortens a string down to the number of characters passed as an argument. If the specified number of characters is less than the length of the string, an ellipsis (…) is appended to the string and is included in the character counttruncatewords— Shortens a string down to the number of words passed as an argument. If the specified number of words is less than the number of words in the string, an ellipsis (…) is appended to the stringunescape— Unescapes HTML escaped textupcase— Makes each character in a string uppercase. It has no effect on strings which are already all uppercaseurl_decode— Decodes a string that has been encoded as a URL or byurl_encodeurl_encode— Converts any URL-unsafe characters in a string into percent-encoded characters
Dates
date— Converts a timestamp into another date format. The format for this syntax is the same as strftime. The input uses the same format as Ruby’s Time.parsedate_add— Adds a unit of time to a date and returns a datestamp in UTC. Valid units are: years, months, weeks, days, hours, minutes, and secondsdatetime— Converts a date/time string to a valid timestampnow— Returns a timestamp for the current date and time for the given timezonetime_ago— Returns a time distance string for a given datetime_duration— Returns a time duration string for a given number of secondstoday— Returns a datestamp for the current date for the given timezone
Records
record_fields— Returns the fields that can be accessed on the recordrecord_name— Returns the name of the recordrecord_relationships— Returns the relationships that can be accessed on the recordrecordize— Returns a record from the liquid object. Not all liquid objects can be converted to a record
Theme
asset_url— Returns the url of an asset in the themet— Returns the translation for a given key for the current locale
URL
params— Adds query params to a url or path
Videos
vimeo— Returns HTML embed code for the supplied Vimeo idyoutube— Returns HTML embed code for the supplied YouTube id
Utilities
default— Sets a default value for any variable which isnil,false, orblank
Product content
Was this article helpful?
Thanks for your feedback! It helps us improve our docs.