Answers.Body: <p>You could also add the Twig <a href="http://twig.sensiolabs.org/doc/filters/raw.html"><code>raw</code></a> filter, which should prevent the automated escaping.</p>
  
  <pre><code>{% set address = contact.address|nl2br|raw %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-09-30T13:56:29.680Z
Answers.Text: Thanks for your answer, and this is what I ended up doing with a small difference because using `|nl2br` and `|raw` together didn't work. A bit strange though that the `|nl2br` filter would encode the `<br />`'s...
Answers.UserDisplayName: bravokiloecho
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-30T18:44:13.797Z
Answers.Text: found a solution?
Answers.UserDisplayName: william
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-09-30T13:10:11.913Z
Answers.LastActivityDate: 2014-09-30T13:21:22.770Z
Answers.LastEditDate: 2014-09-30T13:21:22.770Z
Answers.UserDisplayName: Pascal Mollet
Answers.Body: <p>I'm using Craft v3.1, I noticed that none of the answers worked for me. </p>
  
  <p>I only got it to work by placing <code>raw</code> before <code>nl2br</code>. </p>
  
  <p>This is what worked for me: <code>{{ entry.customFieldName |raw|nl2br }}</code></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-03T19:23:45.923Z
Answers.LastActivityDate: 2019-02-03T19:23:45.923Z
Answers.UserDisplayName: mateostabio
Answers.Body: <p>Just using <code>|nl2br</code> inside a <code>&lt;p&gt;</code> tag (or whatever you choose) worked for me.</p>
  
  <p><code>&lt;p&gt;{{ contact.address|nl2br }}&lt;/p&gt;</code></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-24T10:16:55.273Z
Answers.LastActivityDate: 2017-03-24T10:16:55.273Z
Answers.UserDisplayName: Adam Menczykowski
Answers.Body: <p>Add raw before nl2br</p>
  
  <pre><code>{% set address = contact.address|raw|nl2br %}
  </code></pre>
  
  <p>This will work.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-11T12:58:30.503Z
Answers.LastActivityDate: 2019-12-11T12:58:30.503Z
Answers.UserDisplayName: Ash
Answers.Body: <p>Expanding from <a href="https://craftcms.stackexchange.com/users/149/pascal-mollet">Pascal Mollet</a>'s answer, this was the solution I came up with.</p>
  
  <p>First setting the address variable with the <code>|nl2br</code> filter:</p>
  
  <pre><code>{% set address = contact.address|nl2br %}
  </code></pre>
  
  <p>Then, outputting that variable with the <code>|raw</code> filter:</p>
  
  <pre><code>{{address|raw}}
  </code></pre>
  
  <p>Using them both together at once like this (as Pascal suggested):</p>
  
  <pre><code>{% set address = contact.address|nl2br|raw %}
  </code></pre>
  
  <p>didn't work.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-06T20:18:58.427Z
Answers.Text: I was able to use @Pascal's suggestion successfully - though instead of setting the variable, I just printed out the code like so: `{{ contact.address|nl2br|raw }}`
Answers.UserDisplayName: Ray
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-09-30T14:00:19.607Z
Answers.LastActivityDate: 2014-10-01T08:01:57.390Z
Answers.LastEditDate: 2017-04-13T12:51:00.160Z
Answers.UserDisplayName: bravokiloecho
Body: <p>I'm looking for a way to output line break from a text field.</p>
  
  <p>I'm aware of the "Allow line breaks" option and I have set that to true. I've then entered text with multiple new lines. However, when this text gets output in the template, there are no line breaks.</p>
  
  <p>I have tried using <a href="http://twig.sensiolabs.org/doc/filters/nl2br.html">Twig's new line to br function</a>, like this:</p>
  
  <pre><code>{% set address = contact.address|nl2br %}
  </code></pre>
  
  <p>but this creates <code>&lt;br /&gt;</code> tags in the text, not the markup - that is, you can actually see the <code>&lt;br /&gt;</code> in the browser and no actual line breaks are being created.</p>
  
  <p>Am I doing something wrong here? Are there any alternative solutions?</p>
  
  <p>Thanks!</p>
  
Tags: <templating>
Title: Create line breaks from text field
ThreadText: # Create line breaks from text field
  
  (Asked by: username_0 on 2014-09-30)
  
  I'm looking for a way to output line break from a text field.
  
  I'm aware of the "Allow line breaks" option and I have set that to true. I've then entered text with multiple new lines. However, when this text gets output in the template, there are no line breaks.
  
  I have tried using [Twig's new line to br function](http://twig.sensiolabs.org/doc/filters/nl2br.html), like this:
  
  ```
  {% set address = contact.address|nl2br %}
  
  ```
  
  but this creates `<br />` tags in the text, not the markup - that is, you can actually see the `<br />` in the browser and no actual line breaks are being created.
  
  Am I doing something wrong here? Are there any alternative solutions?
  
  Thanks!
  
  **Tags:** templating
  
  
  ---
  
  ## 5 answers
  
  ### Answer by username_0 on 2014-09-30. Score: 32 | Accepted answer
  
  Expanding from [username_1 username_1](https://craftcms.stackexchange.com/users/149/username_1-username_1)'s answer, this was the solution I came up with.
  
  First setting the address variable with the `|nl2br` filter:
  
  ```
  {% set address = contact.address|nl2br %}
  
  ```
  
  Then, outputting that variable with the `|raw` filter:
  
  ```
  {{address|raw}}
  
  ```
  
  Using them both together at once like this (as username_1 suggested):
  
  ```
  {% set address = contact.address|nl2br|raw %}
  
  ```
  
  didn't work.
  
  > **Comments:**
  > **username_6**: I was able to use @username_1's suggestion successfully - though instead of setting the variable, I just printed out the code like so: `{{ contact.address|nl2br|raw }}`  
  
  ---
  
  ### Answer by username_1 on 2014-09-30. Score: 11
  
  You could also add the Twig [`raw`](http://twig.sensiolabs.org/doc/filters/raw.html) filter, which should prevent the automated escaping.
  
  ```
  {% set address = contact.address|nl2br|raw %}
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks for your answer, and this is what I ended up doing with a small difference because using `|nl2br` and `|raw` together didn't work. A bit strange though that the `|nl2br` filter would encode the `<br />`'s...  
  > **username_2**: found a solution?  
  
  ---
  
  ### Answer by username_3 on 2019-02-03. Score: 2
  
  I'm using Craft v3.1, I noticed that none of the answers worked for me.
  
  I only got it to work by placing `raw` before `nl2br`.
  
  This is what worked for me: `{{ entry.customFieldName |raw|nl2br }}`
  
  
  ---
  
  ### Answer by username_4 on 2017-03-24. Score: 2
  
  Just using `|nl2br` inside a `<p>` tag (or whatever you choose) worked for me.
  
  `<p>{{ contact.address|nl2br }}</p>`
  
  
  ---
  
  ### Answer by username_5 on 2019-12-11. Score: 1
  
  Add raw before nl2br
  
  ```
  {% set address = contact.address|raw|nl2br %}
  
  ```
  
  This will work.
  
  
  ---
  
  