How to Disable JSON REST API in WordPress


WordPress 4.4 has added the much anticipated JSON API and it is a great plugin for developers. However many site owners might not find it very useful and want to disable it. In this article we will explain how to easily disable JSON REST API in WordPress.

Why You Need to Disable JSON REST API in WordPress?

Although API will bring lots of benefits for WordPress developers but some users might not be using those features at all. The API makes it super easy to retrieve data using GET requests. This is extremely useful for those building apps with WordPress.

Having that said, this could potentially open your website to a new front of DDoS attacks. It can be resource intensive and slow down your website.

It is similar to disabling XML-RPC, which many site admins disable on their WordPress sites just to be on the safe side.

Disabling JSON REST API in WordPress

If you want to disable JSON REST API on your WordPress site, then you can easily do so by simply adding the following code in your theme’s functions.php or in a site-specific plugin.

1 add_filter(‘json_enabled’, ‘__return_false’);
2 add_filter(‘json_jsonp_enabled’, ‘__return_false’);


This code simply uses the built-in filters to disable the JSON and JSONP APIs.

For those of you who don’t want to manually add the code, you can install and activate the Disable JSON API plugin. The plugin works out of the box, and there are no settings for you to configure. Simply activating the plugin will disable the API on your site.