WordPress is a popular content management system (CMS) that is widely used by bloggers, businesses, and other website owners. One of the benefits of WordPress is the ability to use the JSON REST API, which allows developers to create custom applications that can interact with a WordPress site. However, there may be times when you want to disable the JSON REST API, either for security or performance reasons. In this article, we will learn how to disable the JSON REST API in WordPress.
There are several ways to disable the JSON REST API in WordPress, including using a plugin or editing the WordPress code directly. Here are the steps you can follow to disable the JSON REST API in WordPress:
Disable JSON REST API using a plugin
You can use the Disable REST API plugin to turn off the JSON REST API in WordPress. This plugin is easy to use and does not require any coding skills. Here are the steps to follow:
Go to Plugins > Add New in your WordPress dashboard.

Search for the Disable REST API plugin and click Install Now and then Activate.

Go to Settings > Disable REST API and check the box to disable the JSON REST API. Then, Click Save Changes.

Disable JSON REST API using code:
If you prefer to edit the WordPress code directly, you can add the following code to your functions.php file:
add_filter('json_enabled', '__return_false'); add_filter('json_jsonp_enabled', '__return_false');
This code will disable both the JSON and JSONP versions of the REST API.
Disable JSON REST API using .htaccess:
You can also disable the JSON REST API using the .htaccess file on your server. Here are the steps to follow:
– Access your website’s .htaccess file using an FTP client or cPanel.
– Add the following code at the end of the file:
# Block WordPress REST API <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_METHOD} ^(PUT|DELETE|CONNECT|OPTIONS|TRACE|PATCH|PROPFIND|PROPPATCH|MKCOL|COPY|MOVE|LOCK|UNLOCK|REPORT)$ [NC] RewriteRule ^(.*)$ - [F,L] </IfModule>
This code will block all HTTP requests to the JSON REST API.
Disable JSON REST API In WordPress FAQ
Here are the most common questions about disabling JSON REST API in WordPress.
No, disabling the JSON REST API will not affect the functionality of your website. However, it may affect any custom applications that rely on the API.
Yes, you can re-enable the JSON REST API by removing the code or plugin that disabled it.
Disabling the JSON REST API may improve your website’s performance by reducing the load on your server.
Editing the WordPress code directly can be risky, as it can cause errors or conflicts with other plugins or themes. It is always recommended to back up your website before making any changes to the code.
Yes, you can use plugins or code snippets to disable the JSON REST API for specific user roles only. This can be useful if you want to restrict access to the API for certain users, while allowing access for others.