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

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

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

## 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
