---
title: "Discussion on \"How to keep line breaks in user input without unescaping it in Laravel\" | Hashnode"
description: "Discussion on \"How to keep line breaks in user input without unescaping it in Laravel\". The problem\nI recently got a question from a client about disappearing line breaks. It was a valid question since the text came from a textarea input that was echoed out on a page. The type of content was really simple and had no need for markup, so ..."
url: "https://hashnode.com/posts/how-to-keep-line-breaks-in-user-input-without-unescaping-it-in-laravel/6291f5b70989e6b52feaf0f1"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [How to keep line breaks in user input without unescaping it in Laravel](https://stefrouschop.nl/how-to-keep-line-breaks-in-user-input-without-unescaping-it-in-laravel?utm_source=hashnode&utm_medium=feed)

The problem I recently got a question from a client about disappearing line breaks. It was a valid question since the text came from a textarea input that was echoed out on a page. The type of content was really simple and had no need for markup, so ...

May 28, 2022 · 3 min read · stefrouschop.nl  
Read the article

-   [#laravel](https://hashnode.com/tag/laravel)

## Written by

[Stef Rouschop](https://hashnode.com/@stefrouschop)

@stefrouschop · Ulestraten, The Netherlands

  
[View profile](https://hashnode.com/@stefrouschop)

Laravel Developer at Code Runway B.V.

Lead developer at 3rdRisk.com. Proud father of two kids. Tech optimist. Apple and Laravel enthusiast.

## Responses 2

Markdown supported · ⌘↵ to post

[Mark Snape](https://hashnode.com/@Snapey)

[Jun 3, 2022](https://hashnode.com/posts/how-to-keep-line-breaks-in-user-input-without-unescaping-it-in-laravel/6291f5b70989e6b52feaf0f1/comment/629a929d70302328c80b63bb)

I try to use CSS, but failing that, my preferred pattern is

```
{!! nl2br(e($description)) !!}
```

the e() function escapes the content, then you convert the newlines and finally, safely echo the raw content

[Said Bakr](https://hashnode.com/@saidbakr)

[May 28, 2022](https://hashnode.com/posts/how-to-keep-line-breaks-in-user-input-without-unescaping-it-in-laravel/6291f5b70989e6b52feaf0f1/comment/62925672d97f80b5091d9b35)

The blade component implementation is new for me. I have used to Blade Service Provider in Laravel 5.4. What is the version of Laravel that started such theses components?

[Stef Rouschop](https://hashnode.com/@stefrouschop)

[May 28, 2022](https://hashnode.com/posts/how-to-keep-line-breaks-in-user-input-without-unescaping-it-in-laravel/6291f5b70989e6b52feaf0f1/comment/62925672d97f80b5091d9b35#reply-6292597b0989e6b52feafdbd)

I’m not sure, but I think they were introduced in Laravel 7.
