{"title":"truncatewords - Liquid Filter Reference","slug":"truncatewords-filter-reference","url":"https://support.storeconnect.com/articles/truncatewords-filter-reference","url_markdown":"https://support.storeconnect.com/articles/truncatewords-filter-reference.md","subtitle":null,"summary":"Shortens a string to a maximum word count, appending an ellipsis by default. A second argument lets you customize or remove the trailing characters.","type":"Developer_Documentation","video_url":"","keywords":"liquid, filters, truncatewords, text, storeconnect","last_modified":"2026-08-21T07:12:35+0000","body_markdown":"## Description\n\nShortens 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 string.\n\n| Property | Value |\n|----------|-------|\n| **Return Type** | string |\n| **Category** | text |\n\n## Examples\n\n\n```liquid\n\n{{ \"Mary had a little lamb.\" | truncatewords: 3 }}\n```\n\n\n**Output:** `Mary had a...`\n\n`truncatewords` takes an optional second argument that specifies the sequence of characters to be appended to the truncated string. By default this is an ellipsis (…), but you can specify a different sequence\n\n\n```liquid\n\n{{ \"Mary had a little lamb.\" | truncatewords: 3, \"--\" }}\n```\n\n\n**Output:** `Mary had a--`\n\nYou can avoid showing trailing characters by passing a blank string as the second argument\n\n\n```liquid\n\n{{ \"Mary had a little lamb.\" | truncatewords: 3, \"\" }}\n```\n\n\n**Output:** `Mary had a`"}