---
title: "Spaceless ViewHelper <f:spaceless>"
manual: "Fluid Explained"
version: "main"
permalink: "https://docs.typo3.org/permalink/fluid:typo3fluid-fluid-spaceless"
source: "ViewHelpers/Fluid/Spaceless.rst"
rendered: "2026-10-08T14:12:40+00:00"
---

# Spaceless ViewHelper `<f:spaceless>` {#typo3fluid-fluid-spaceless}

> [!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/Spaceless.html) instead.

Space Removal ViewHelper

Removes redundant spaces between HTML tags while
preserving the whitespace that may be inside HTML
tags. Trims the final result before output.

Heavily inspired by Twig's corresponding node type.

## Usage of f:spaceless {#usage-of-f-spaceless}

```php
<f:spaceless>
    <div>
        <div>
            <div>text

    text</div>
        </div>
    </div>
</f:spaceless>

```

Output:

```php
<div><div><div>text

text</div></div></div>
```

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