How to Fix the Invalid JSON Error in WordPress?

The Invalid JSON Error in WordPress is quite a drawback for WordPress users while working. This error tends to appear while you are editing WordPress posts or pages on your site.

Most of the time, the error appears as “The response is not a valid JSON response”. In case you update it, this will fail. Getting an error message like this while you are working can disrupt your editing.

So, how do you fix this invalid JSON error on your WordPress site? Here is a complete guide on it.

Have a look:

What is the reason behind this error?

The Invalid JSON Error in WordPress has some significant reasons that cause this while you keep on editing. In case there is any kind of failure while receiving an expected response from the server you are using, it can cause a JSON response error.

There is a need for communication between WordPress and the Server while you are editing your blog post. It completely relies on the responses it is getting from the web hosting server, which is running in the background.

This response usually comes in the format of JSON, which is used for quickly transporting the data with the help of JavaScript.

Invalid JSON Error in WordPress

If, due to some reason, the WordPress fails to receive the response, or in case the response is not in the JSON format, then you are going to see that “Not a valid JSON response” error.

Not a valid JSON response

This error can appear due to many reasons. However, the most prominent cause of it is the incorrect URL and settings in WordPress or broken permalinks.

This is why it is important to make a complete WordPress backup before you are making any of the bigger changes to your website. It allows you to restore your website easily to its previous state.

How do you fix it, in case it keeps happening with you?

1. Start with checking your WordPress URLs in the settings area:

First of all, you need to ensure that the WordPress Address and Site Address settings that you are adding are completely correct. Then you simply need to go to the Settings >> General page. From that place, you need to review your WordPress address URL and the fields of the Site Address URL.

general settings

For the type of your website, these settings need to have a similar URL in both of the fields. On the other hand, some of the users may have padded the WordPress with their directory and serve the website with a different address. In such cases, they can have different URLs here in this area.

In case your Site Address is not valid, then it can cause an invalid JSON error in WordPress. In case you are making any kind of changes to the settings, then you have to click on the Save Changes button to save all the settings.

You can also edit blog posts and see in case adding any of the new blocks or saving that post is triggering the response error or not.

In case you are still encountering the error, then you have to go to the next step.

2. Consider Fixing your WordPress Permalink Structure

In case you are still getting the Invalid JSON Error in WordPress after fixing your WordPress URL, then you have to fix your WordPress permalink structure.

WordPress usually comes along with a very SEO-friendly URL structure. It lets you use human-readable URLs used for your post and page areas.

fixing permalink settings

However, users can also mess up with the permalink settings. It will make things impossible for the WordPress editor to generate a vaping response of JSON. Hence the error will keep showing up.

However, you can fix this easily. For that, you have to visit the Settings >> Permalinks page. From this place, you need to review the options for the permalink.

In case you are not sure whether you are using the proper settings or not, then you simply have to select the default formats which are available there.

After that, you can go forward and click on the Save Changes button to store your settings. You can now opt for editing a blog post or the page on your WordPress to see in case any errors are still there or not. If the error is still occurring, then you have to go to the next step.

3. You have to generate the WordPress .htaccess file again:

The .htaccess file in the WordPress area is used as the file for the configuration file. It helps in managing SEO-friendly URLs or permalinks.

WordPress can auto-generate and update it. You can also trigger this update with a simple click on the Save Changes button at the button area of the Settings >> Permalinks page.

generate the WordPress .htaccess

But sometimes, it may not get the update in case there is something wrong in the settings. It will affect the permalinks of your WordPress site. Also, this may cause an invalid response error in JSON format.

For fixing this up, you need to connect with your website with the help of the FTP client or the file manager application that you are using in the dashboard of your WordPress hosting account.

download the WordPress .htaccess

As you have connected it, you need to relocate its .htaccess file from the root folder area of your website. Then you can download it as a backup on your computer.

As the file opens, you need to delete all the codes in it. Then replace it with this code:

# BEGIN WordPress

RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

After that, save all your changes and upload the file back to your site. You can also visit the website and edit the post or the page. To see in case, you can reproduce the invalid JSON response error or not. In case you are still seeing the error, then go to the next step:

4. Review your API debug log

This invalid JSON response error can also mean that the WordPress Rest API on your website is dealing with an error.

The REST API comes as the set of techniques that WordPress uses for communicating with the server as you tend to work on your website. You can also see details related to this error in the WordPress Site Health tool. Visit the Tools> Site Health area.

Review your API debug log

Here you can see the issue related to your REST API. Click on it to see more details that can give you clues about the plugin or the third-party service which is causing this issue. If it is not working, then you can step forwards to the next solution.

5. Consider deactivating all your plugins in WordPress:

In some of the cases, your WordPress plugin may conflict with each other, which can create such errors. It results in the potential reason for the JSON error that you keep receiving. To resolve this issue, go to the Plugins >> Installed Plugins page.

Here you need to select all of your WordPress plugins. Then choose the Deactivate option under the Bulk Actions to drop down the menu. Then click on the Apply button to continue further.

plugins settings

WordPress now will deactivate all of the installed plugins that you have added to it.

Now, work again on reproducing the error. If the error disappears, then it is completely fine. However, you need to figure out, which plugin is causing it.

For that, you need to activate them one after another and try reproducing the error. You have to continue with this until you find the actual problem causing one.

6. Make a temporary switch to the classic editor:

You can temporarily switch to the classic editor in case none of the above-mentioned ones work. The older version of the WordPress editor works with a very simple text editor, which does not rely on the JSON or REST API response.

Install and activate the Classic Editor plugin. This plugin will disable your Gutenberg editor after the activation.

7. Troubleshoot further:

Various reasons can work together to block your WordPress REST API and make it return as the JSON response. In such cases, you have to address it to work on it. If none of the above methods work, you have to follow some more steps. Here is what you can do:

  • Switch to the default theme of WordPress:
  • To deal with the Invalid JSON Error in WordPress, you can switch to your default theme as it sometimes create conflicts. You can make a simple switch between two themes to check why it keeps happening.

  • Turn off your Website Application Firewall temporarily:
  • In case you are using Sucuri, Cloudflare, etc., then it is possible that they may block some of the legitimate requests.
    So, you can disable some of the application-level WordPress firewalls. For the DNS level firewalls, you can disable them from the account dashboard.

  • Turn on the debug in the WordPress:
  • WordPress comes along with a built-in feature that allows you to keep a log of errors. But it is not enabled by default. To turn it on, you have to add the following code to your wp-config.php.file area:

    define( ‘WP_DEBUG’, true );
    define( ‘WP_DEBUG_LOG’, true );

    After this, WordPress will keep a log for all errors in the debug.log file located in the wp/content/folder. You can access this file with the FTP client. It can give you a clue about the error.

  • Seek out expert help:
  • In case none of the above is working, you can go seeking expert help. If there is a misconfiguration in your hosting server, then it can keep happening. Reach out to the experts who can help you.


The Invalid JSON Error in WordPress can disrupt your editing, but it is easier to resolve if you follow the above-mentioned methods. Fixing this will retain your work and help you to continue editing.

About Sonnal S Sinha

Sonnal S SinhaSonnal S Sinha shares exciting WordPress themes, plugins and other WordPress related news for our viewers. He also posts selected WordPress developers interviews from time to time.