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

# Variable ViewHelper `<f:variable>` {#typo3fluid-fluid-variable}

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

Variable assigning ViewHelper

Assigns one template variable which will exist also
after the ViewHelper is done rendering, i.e. adds
template variables.

If you require a variable assignment which does not
exist in the template after a piece of Fluid code
is rendered, consider using `f:alias` ViewHelper instead.

Usages:

```php
{f:variable(name: 'myvariable', value: 'some value')}
<f:variable name="myvariable">some value</f:variable>
{oldvariable -> f:format.htmlspecialchars() -> f:variable(name: 'newvariable')}
<f:variable name="myvariable"><f:format.htmlspecialchars>{oldvariable}</f:format.htmlspecialchars></f:variable>
```

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

**Arguments**

The following arguments are available for the variable ViewHelper:

-   **name**

    -   *Type:* string
    -   *Required:* true

    Name of variable to create

-   **value**

    -   *Type:* mixed

    Value to assign. If not in arguments then taken from tag content
