<p>Sounds like you're looking for the Twig <a href="https://twig.symfony.com/doc/2.x/filters/striptags.html" rel="nofollow noreferrer">|striptags</a> filter, which is a wrapper for PHP's <a href="https://www.php.net/manual/en/function.strip-tags.php" rel="nofollow noreferrer">strip_tags</a></p>

CC BY-SA 4.0
2019-04-22T22:56:27.460Z
2019-04-22T22:56:27.460Z
Brad Bell
<p>I'm looking to purge all the <code>html</code> from a text field, but leave the line breaks in there. I currently have the following code, which makes line breaks happen, but unfortunately, people can add <code>html</code> to the text field and it will render it.</p>

<pre><code>    {{ user.userAbout|raw }}
</code></pre>

<p>Is there any way to do this?</p>

<templating>
Purge HTML but leave Line Breaks
# Purge HTML but leave Line Breaks

(Asked by: username_0 on 2019-04-18)

I'm looking to purge all the html from a text field, but leave the line breaks in there. I currently have the following code, which makes line breaks happen, but unfortunately, people can add html to the text field and it will render it.
    {{ user.userAbout|raw }}

Is there any way to do this?

**Tags:** templating


---

## 1 answers

### Answer by username_1 on 2019-04-22. Score: 2 | Accepted answer

Sounds like you're looking for the Twig [|striptags](https://twig.symfony.com/doc/2.x/filters/striptags.html) filter, which is a wrapper for PHP's [strip\_tags](https://www.php.net/manual/en/function.strip-tags.php)


---

