---
title: "Format.trim ViewHelper <f:format.trim>"
manual: "Fluid Explained"
version: "main"
permalink: "https://docs.typo3.org/permalink/fluid:typo3fluid-fluid-format-trim"
source: "ViewHelpers/Fluid/Format/Trim.rst"
rendered: "2026-09-26T08:24:58+00:00"
---

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

> [!NOTE]
> This reference is part of the documentation of Fluid Standalone.
> If you are working with Fluid in TYPO3 CMS, please refer to
> [TYPO3's ViewHelper reference](https://docs.typo3.org/other/typo3/view-helper-reference/14.3/en-us/Global/Format/Trim.html) instead.

This ViewHelper strips whitespace (or other characters) from the beginning and end of a string.

Possible sides are:

-   **`both` (default)**

    Strip whitespace (or other characters) from the beginning and end of a string

-   **`left` or `start`**

    Strip whitespace (or other characters) from the beginning of a string

-   **`right` or `end`**

    Strip whitespace (or other characters) from the end of a string

## Examples {#examples}

### Defaults {#defaults}

```php
#<f:format.trim>   String to be trimmed.   </f:format.trim>#

```

```text
#String to be trimmed.#
```

### Trim only one side {#trim-only-one-side}

```php
#<f:format.trim side="right">   String to be trimmed.   </f:format.trim>#

```

```text
#   String to be trimmed.#
```

### Trim special characters {#trim-special-characters}

```php
#<f:format.trim characters=" St.">   String to be trimmed.   </f:format.trim>#

```

```text
#ring to be trimmed#
```

### Inline usage {#inline-usage}

```php
#{f:format.trim(value: my_variable)}#
#{my_variable -> f:format.trim()}#
```

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

**Arguments**

The following arguments are available for the format.trim ViewHelper:

-   **characters**

    -   *Type:* string

    Optionally, the stripped characters can also be specified using the characters parameter. Simply list all characters that you want to be stripped. With .. you can specify a range of characters.

-   **side**

    -   *Type:* string
    -   *Default:* 'both'

    The side to apply, must be one of this' CASE\_\* constants. Defaults to both application.

-   **value**

    -   *Type:* string

    The string value to be trimmed. If not given, the evaluated child nodes will be used.
