Keep line breaks in Shopify Multi-line Metafield

With the text metafield, you have the option to choose multi-lines. This will display with line breaks in a dynamic field.

However, if you are using custom Liquid code to display this field, you’ll need a filter to keep the line breaks.

Let’s start with our initial code:

{{ product.metafields.my_fields.multi_text}}

Now add the filter by using a pipe “|” and add newline_to_br:

{{ product.metafields.my_fields.multi_text | newline_to_br }}

Now this will keep the line breaks when using this field.

Keep in mind that any HTML in this field will be display if you use this in a dynamic Rich Text block. If you need to keep HTML formatting use a custom liquid block or edit theme code directly.

Scroll to Top