A developer needed to convert a multi-line text metafield into individual <li> elements in Shopify Liquid. Initial attempts using split with \n or \r\n failed, returning all values in a single list item.
Solution Found:
The issue was resolved using Liquid filters to parse newlines:
{% assign text = product.metafields.custom.product_usp_list.value %}
{% assign lines = text | newline_to_br | strip_newlines | split: "<br />" %}
This converts newlines to <br /> tags, strips them, then splits on the tags to create an array.
Alternative Approaches Discussed:
Using a “list of single line text” metafield type with metafield_tag filter
Capturing newlines directly with {% capture newline %} (recommended as more stable, since Shopify historically changed <br> to <br />)
Outcome:
The developer successfully implemented the <br /> split method. They initially misunderstood the “list of single line text” suggestion but later clarified that this metafield type doesn’t require preset choices—it’s configured by selecting “list of values” when defining a “Single line text” metafield.
Summarized with AI on October 24.
AI used: claude-sonnet-4-5-20250929.
@tim_1 Ok just to be sure: With the first way you are referring to a “single_line_text” field and with the option “Limit to preset choices“??
I could not find the exact `list of single line text` so I thought you were referring to that.
Is that correct or did I miss something? (I’m new to Shopify )
And, no, “list of single line text” does not have to be limited to predefined choices.
When you define your metafield you have a choice whether is will be a single value or a list of values.
So you first define metafield type as a “Single line text” and then select a “list of values”.