---
title: "Format.nl2br ViewHelper <f:format.nl2br>"
manual: "Fluid ViewHelper Reference"
version: "14.3"
permalink: "https://docs.typo3.org/permalink/t3viewhelper:typo3fluid-fluid-format-nl2br@14.3"
source: "Global/Format/Nl2br.rst"
rendered: "2026-10-01T16:43:06+00:00"
---

# Format.nl2br ViewHelper `<f:format.nl2br>` {#typo3fluid-fluid-format-nl2br}

<!-- TODO: no Markdown rendering for "versionchanged" -->

The Render.text ViewHelper <f:render.text>
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@14.3)
-   [Arguments of the <f:format.nl2br> ViewHelper](https://docs.typo3.org/permalink/t3viewhelper:arguments-of-the-f-format-nl2br-viewhelper@14.3)

## Preserving line breaks in HTML output {#typo3-fluid-format-nl2br-example}

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 {#typo3-fluid-format-nl2br-arguments}

-   **value**

    -   *Type:* string

    string to format
