Skip to main content

size

variable | size
returns number

Returns the size of a string or array.

The size of a string is the number of characters that the string includes. The size of an array is the number of items in the array.

{{ collection.title | size }}
{{ collection.products | size }}

Output

12
4

You can use the size filter with dot notation when you need to use it inside a tag or object output.

{% if collection.products.size >= 10 %}
There are 10 or more products in this collection.
{% else %}
There are less than 10 products in this collection.
{% endif %}

Output

There are less than 10 products in this collection.
Was this page helpful?