Title: rest_json_encode_options
Published: November 2, 2022
Last modified: April 28, 2025

---

# apply_filters( ‘rest_json_encode_options’, int $options, WP_REST_Request $request )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/hooks/rest_json_encode_options/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/rest_json_encode_options/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/rest_json_encode_options/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/rest_json_encode_options/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/hooks/rest_json_encode_options/?output_format=md#wp--skip-link--target)

Filters the JSON encoding options used to send the REST API response.

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/rest_json_encode_options/?output_format=md#parameters)󠁿

 `$options`int

JSON encoding options [json_encode()](https://developer.wordpress.org/reference/functions/json_encode/).

`$request`[WP_REST_Request](https://developer.wordpress.org/reference/classes/wp_rest_request/)

Current request object.

## 󠀁[Source](https://developer.wordpress.org/reference/hooks/rest_json_encode_options/?output_format=md#source)󠁿

    ```php
    return apply_filters( 'rest_json_encode_options', $options, $request );
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/rest-api/class-wp-rest-server.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/rest-api/class-wp-rest-server.php#L266)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/rest-api/class-wp-rest-server.php#L266-L266)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/rest_json_encode_options/?output_format=md#related)󠁿

| Used by | Description | 
| [WP_REST_Server::get_json_encode_options()](https://developer.wordpress.org/reference/classes/wp_rest_server/get_json_encode_options/)`wp-includes/rest-api/class-wp-rest-server.php` |

Gets the encoding options passed to wp_json_encode.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/rest_json_encode_options/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.1.0](https://developer.wordpress.org/reference/since/6.1.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Frest_json_encode_options%2F)
before being able to contribute a note or feedback.