newline_to_br
Insert HTML break elements (<br />) before each newline character in a multiline string.
Syntax
{{ multiline_string | newline_to_br }}Example
{% assign notes = "Line 1
Line 2" %}{{ notes | newline_to_br }}Output
Line 1<br />
Line 2The newline_to_br filter detects newline characters in text strings and inserts an HTML <br /> break tag before each one, preserving paragraph formatting in HTML view.
In programmatic keyword generation, newline_to_br displays multiline address blocks or policy disclaimers from spreadsheet cells without losing line breaks. For example: {{ row.office_address | newline_to_br }}. This renders mailing addresses cleanly in structured footer cards across every generated city landing page.
Filters
- abs
- append
- at_least
- at_most
- capitalize
- ceil
- compact
- concat
- date
- default
- divided_by
- downcase
- escape
- escape_once
- first
- floor
- join
- last
- lstrip
- map
- minus
- modulo
- newline_to_br
- plus
- prepend
- remove
- remove_first
- replace
- replace_first
- reverse
- round
- rstrip
- size
- slice
- sort
- sort_natural
- split
- strip
- strip_html
- strip_newlines
- times
- truncate
- truncatewords
- uniq
- upcase
- url_decode
- url_encode
- where
- raw
- slugify
- number_format
