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

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

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

Wrapper for PHPs `json_encode` function.
See [https://www.php.net/manual/function.json-encode.php](https://www.php.net/manual/function.json-encode.php).

## Examples {#examples}

### Encoding a view variable {#encoding-a-view-variable}

```php
{someArray -> f:format.json()}

```

`["array","values"]`
Depending on the value of `{someArray}`.

### Associative array {#associative-array}

```php
{f:format.json(value: {foo: 'bar', bar: 'baz'})}

```

`{"foo":"bar","bar":"baz"}`

### Non associative array with forced object {#non-associative-array-with-forced-object}

```php
{f:format.json(value: {0: 'bar', 1: 'baz'}, forceObject: true)}

```

`{"0":"bar","1":"baz"}`

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

**Arguments**

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

-   **forceObject**

    -   *Type:* bool
    -   *Default:* false

    Outputs an JSON object rather than an array

-   **value**

    -   *Type:* mixed

    The incoming data to convert, or null if VH children should be used
