Title: wp_oembed_ensure_format
Published: December 9, 2015
Last modified: February 24, 2026

---

# wp_oembed_ensure_format( string $format ): string

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/wp_oembed_ensure_format/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_oembed_ensure_format/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_oembed_ensure_format/?output_format=md#source)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_oembed_ensure_format/?output_format=md#changelog)

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

Ensures that the specified format is either ‘json’ or ‘xml’.

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

 `$format`stringrequired

The oEmbed response format. Accepts `'json'` or `'xml'`.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_oembed_ensure_format/?output_format=md#return)󠁿

 string The format, either `'xml'` or `'json'`. Default `'json'`.

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

    ```php
    function wp_oembed_ensure_format( $format ) {
    	if ( ! in_array( $format, array( 'json', 'xml' ), true ) ) {
    		return 'json';
    	}

    	return $format;
    }
    ```

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

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

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

## User Contributed Notes

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