Title: wp_is_json_request
Published: December 6, 2018
Last modified: February 24, 2026

---

# wp_is_json_request(): bool

## In this article

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

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

Checks whether current request is a JSON request, or is expecting a JSON response.

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

 bool True if `Accepts` or `Content-Type` headers contain `application/json`.
 False
otherwise.

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

    ```php
    function wp_is_json_request() {
    	if ( isset( $_SERVER['HTTP_ACCEPT'] ) && wp_is_json_media_type( $_SERVER['HTTP_ACCEPT'] ) ) {
    		return true;
    	}

    	if ( isset( $_SERVER['CONTENT_TYPE'] ) && wp_is_json_media_type( $_SERVER['CONTENT_TYPE'] ) ) {
    		return true;
    	}

    	return false;
    }
    ```

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

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

| Uses | Description | 
| [wp_is_json_media_type()](https://developer.wordpress.org/reference/functions/wp_is_json_media_type/)`wp-includes/load.php` |

Checks whether a string is a valid JSON Media Type.

  |

| Used by | Description | 
| [determine_locale()](https://developer.wordpress.org/reference/functions/determine_locale/)`wp-includes/l10n.php` |

Determines the current locale desired for the request.

  | 
| [plugins_api()](https://developer.wordpress.org/reference/functions/plugins_api/)`wp-admin/includes/plugin-install.php` |

Retrieves plugin installer pages from the WordPress.org Plugins API.

  | 
| [wp_debug_mode()](https://developer.wordpress.org/reference/functions/wp_debug_mode/)`wp-includes/load.php` |

Sets PHP error reporting based on WordPress debug settings.

  | 
| [wp_die()](https://developer.wordpress.org/reference/functions/wp_die/)`wp-includes/functions.php` |

Kills WordPress execution and displays HTML page with an error message.

  | 
| [is_admin_bar_showing()](https://developer.wordpress.org/reference/functions/is_admin_bar_showing/)`wp-includes/admin-bar.php` |

Determines whether the admin bar should be showing.

  |

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

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

## User Contributed Notes

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