---
title: "Format.nl2br ViewHelper <f:format.nl2br>"
manual: "Fluid ViewHelper Reference"
version: "main"
permalink: "https://docs.typo3.org/permalink/t3viewhelper:typo3fluid-fluid-format-nl2br@main"
source: "Global/Format/Nl2br.rst"
modified: "2026-09-17T05:12:06+00:00"
---

# Format.nl2br ViewHelper `<f:format.nl2br>`

> [!NOTE]
> **Changed in version 14.0**
>
> The [Render.text ViewHelper \<f:render.text>](https://docs.typo3.org/permalink/t3viewhelper:typo3-fluid-render-text@main)
> should be used whenever text fields from records are
> displayed in HTML output.
>
> Depending on the TCA definition of the rendered field `nl2br` is then
> automatically applied for multi line text areas.

Wrapper for PHPs `nl2br` function.
See [https://www.php.net/manual/function.nl2br.php](https://www.php.net/manual/function.nl2br.php).

Go to the source code of this ViewHelper: [Format\\Nl2brViewHelper.php (GitHub)](https://github.com/TYPO3/Fluid/blob/main/src/ViewHelpers/Format/Nl2brViewHelper.php).

**Table of contents**

-   [Preserving line breaks in HTML output](https://docs.typo3.org/permalink/t3viewhelper:preserving-line-breaks-in-html-output@main)
-   [Arguments of the <f:format.nl2br> ViewHelper](https://docs.typo3.org/permalink/t3viewhelper:arguments-of-the-f-format-nl2br-viewhelper@main)

## Preserving line breaks in HTML output

HTML ignores line breaks within text. To display text while preserving line
breaks, you must convert newline characters such as `\n` or `\r\n` into
HTML line break elements `<br />`.

The `<f:format.nl2br>` ViewHelper uses PHP's
[nl2br()](https://www.php.net/manual/en/function.nl2br.php) function
to insert HTML line breaks.

**User input**

```plaintext
This is
a
string
```

```html
<f:format.nl2br>{userInput}</f:format.nl2br>
```

or inline:

```html
{userInput -> f:format.nl2br()}
```

**Output**

```html
This is<br />
a<br />
string
```

## Arguments of the `<f:format.nl2br>` ViewHelper

-   **value**

    -   *Type:* string

    string to format
