# ResponseFormatterInterface

> ResponseFormatterInterface specifies the interface needed to format a response before it is sent out.

[API reference](/docs/api/index.md) › [yii](/docs/api/yii/index.md) › [web](/docs/api/yii/web/index.md) › ResponseFormatterInterface

| interface | `yii\web\ResponseFormatterInterface` |
| --- | --- |
| Since | 2.0 |
| Source | [`framework/web/ResponseFormatterInterface.php`](https://github.com/yiisoft/yii2/blob/22.0/framework/web/ResponseFormatterInterface.php#L17) |

Implemented by 3 types:

- [`HtmlResponseFormatter`](/docs/api/yii/web/htmlresponseformatter/index.md)
- [`JsonResponseFormatter`](/docs/api/yii/web/jsonresponseformatter/index.md)
- [`XmlResponseFormatter`](/docs/api/yii/web/xmlresponseformatter/index.md)

ResponseFormatterInterface specifies the interface needed to format a response before it is sent out.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`format()`](#method-format) abstract | Formats the specified response. | `ResponseFormatterInterface` |

## Method details

### format() <span id="method-format"></span>

```php
abstract public function format(yii\web\Response $response): mixed
```

Formats the specified response.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$response` | [`Response`](/docs/api/yii/web/response/index.md) | The response to be formatted. |

**Returns**

`mixed`