---
title: "Sanitize.html ViewHelper <f:sanitize.html>"
manual: "Fluid ViewHelper Reference"
version: "main"
permalink: "https://docs.typo3.org/permalink/t3viewhelper:typo3-fluid-sanitize-html@main"
source: "Global/Sanitize/Html.rst"
rendered: "2026-09-26T06:08:28+00:00"
---

# Sanitize.html ViewHelper `<f:sanitize.html>` {#typo3-fluid-sanitize-html}

ViewHelper to pass a given content through `typo3/html-sanitizer` to mitigate potential cross-site scripting occurrences. The `build` option by default uses the class `TYPO3\CMS\Core\Html\DefaultSanitizerBuilder`, which declares allowed HTML tags, attributes and their values.

Go to the source code of this ViewHelper: [Sanitize\\HtmlViewHelper.php (GitHub)](https://github.com/TYPO3/typo3/blob/main/typo3/sysext/fluid/Classes/ViewHelpers/Sanitize/HtmlViewHelper.php).

**Table of contents**

-   [Examples](https://docs.typo3.org/permalink/t3viewhelper:examples@main)
-   [Arguments of the <f:sanitize.html> ViewHelper](https://docs.typo3.org/permalink/t3viewhelper:arguments-of-the-f-sanitize-html-viewhelper@main)

## Examples {#typo3-fluid-sanitize-html-example}

### Default parameters {#typo3-fluid-sanitize-html-default-parameters}

**packages/my_extension/Resources/Private/Templates/Content/Text.fluid.html**

```html
<f:sanitize.html>
  <img src="/img.png" class="image" onmouseover="alert(document.location)">
</f:sanitize.html>
```

**Output**

```html
<img src="/img.png" class="image">
```

### Inline notation {#typo3-fluid-sanitize-html-inline-notation}

**packages/my_extension/Resources/Private/Templates/Content/Text.fluid.html**

```html
{richTextFieldContent -> f:sanitize.html(build: 'default')}
```

## Arguments of the `<f:sanitize.html>` ViewHelper {#typo3-fluid-sanitize-html-arguments}

-   **build**

    -   *Type:* string
    -   *Default:* 'default'

    preset name or class-like name of sanitization builder
