{"title":"slice - Liquid Filter Reference","slug":"slice-filter-reference","url":"https://support.storeconnect.com/articles/slice-filter-reference","url_markdown":"https://support.storeconnect.com/articles/slice-filter-reference.md","subtitle":null,"summary":"Extracts a substring or sub-list starting at a given index, with an optional length. Negative indices count from the end of the string or list.","type":"Developer_Documentation","video_url":"","keywords":"liquid, filters, slice, general, storeconnect","last_modified":"2026-08-21T07:12:35+0000","body_markdown":"## Description\n\nReturns a substring of one character or series of list items beginning at the index specified by the first argument. An optional second argument specifies the length of the substring or number of list items to be returned.\n\n| Property | Value |\n|----------|-------|\n| **Return Type** | any |\n| **Category** | general |\n\n## Examples\n\n\n```liquid\n\n{{ \"Earthquake\" | slice: 0 }}\n```\n\n\n**Output:** `E`\n\n\n```liquid\n\n{{ \"Earthquake\" | slice: 2 }}\n```\n\n\n**Output:** `r`\n\n\n```liquid\n\n{{ \"Earthquake\" | slice: 2, 5 }}\n```\n\n\n**Output:** `rthqu`\n\nHere the input value is an list\n\n\n```liquid\n\n{{ an_list | slice: 1, 2 }}\n```\n\n\n**Output:** `waterair`\n\nIf the first argument is a negative number, the indices are counted from the end of the string\n\n\n```liquid\n\n{{ \"Earthquake\" | slice: -3, 2 }}\n```\n\n\n**Output:** `ak`"}