Fixing the Invalid JSON Error in WordPress


· 12th May 2021·Website Maintenance, Fixing WordPress errors


The error occurs in cases when you are making changes to your WP posts and pages. You will see the message “The response is not a valid JSON response” which will prevent you from updating that post.

Fixing the Invalid JSON Error in WordPress

The error occurs in cases when you are making changes to your WP posts and pages. You will see the message “The response is not a valid JSON response” which will prevent you from updating that post.

Today we will talk about how to easily fix this error and how to avoid it in the future.

What is the reason for the Invalid JSON Error in WordPress?

The error is caused by a failure to receive an expected response from the server. In short, WP needs to communicate with the server during the time you are editing your post. It receives responses from the web hosting server, which are usually in JSON format used to transport data using JavaScript.

If there is failure to respond, or the format is different from JSON, you will see the error message.

reason for the Invalid JSON Error i

There are a number of reasons the error could appear. In most cases it usually occurs when there is an incorrect URL setting in WP or some broken permalinks.

Now, let’s talk about how to easily fix the Invalid JSON Error in WordPress.

Note: Don’t forget to make a backup of your website prior to any big changes, as this would allow you to restore it to its previous state.

WordPress URLs in Settings

The first thing you need to make sure is that the settings of your WP address and website address are correct.

Go to Settings – General, where you need to review the WordPress Address and Site Address fields.

Settings – General

In most cases, the URL needs to be the same in both fields.

However, some users might have provided WP its own directory, serving the site on a different address. In such cases, the URLs can be different.

If the Site address is incorrect this will trigger the error message.

Make your changes, save them and go back to your website to continue editing your post. If the error continues to appear, continue reading bellow.

Fix the WP permalink structure

WordPress is created with a friendly SEO URL structure in mind which allows the URLs for posts and pages to be human-readable.

There are certain cases, however, when a user can mess up the permalink settings. To resolve this, go to Settings – Permalinks and carefully review the options for permalink.

WP permalink structure

If you are not sure which is the correct setting, just use one of the default options.

Now, click on Save changes. Go back and try to edit your post to see of the error remains. If it’s still there, try the next step.

Regenerating WP .htaccess file

The .htaccess file is a configuration file which manages SEO friendly URLs.

Usually, WP automatically regenerates and updates it. You can also manually do this from Settings – Permalinks.

In some cases, however, it does not automatically update or the settings are incorrect. This affects your permalinks and causes the error.

In order to resolve this, log into your site using an FTP client or File manage app. Once there, locate the .htaccess file inside the root folder and download it on your computer

Regenerating WP .htaccess file

Now, you need to edit the .htaccess file using the FTP client.


Delete all the code inside and replace it with the following lines:


Save all changes and upload to file to your website.

Go back to editing your post and check if the JSON error is still there.

If that’s the case, there are a few more things we can do.

Check the Rest API Debug Log

The error also means that WP REST API has encountered an error.

This is the set of techniques WP uses in order to communicate with the server as you work on your site.

Visit the WP Site Health tool where you can check the error details. Click on Tools – Site Health.

site health

You should now see the issues labeled The REST API encountered an unexpected result.

This will show you more info on which plugin or 3rd party service might be causing the issue.

If that doesn’t help, move on to the next step.

Deactivate all plugins

In some cases, there might be a conflict with the plugins. This could lead to unexpected changes and the reason for the JSON error.

Go to Plugins – Installed Plugins. Choose all plugins and click on Deactivate from the bulk action menu. Now, click on Apply.

Deactivate all plugins

All of your plugins will now be deactivated.

Go back and try to reproduce the error. If it’s gone, this means one of the plugins is causing the issue.

In order to figure out which one is the culprit, deactivate them all one by one and try to reproduce the error. Do this until you find the faulty plugin.

Switch back to the classic editor

If all of the above fails, temporary go back to the classic WP editor.

It uses a simple text editor which does not rely on REST API for JSON response.

To do this, download and activate the Classic Editor plugin, which disables the Gutenberg editor once activated.

More Troubleshooting

There are a number of reasons which could lead to blocking the WP REST API or cause the error. If none of the steps above were helpful, there are some alternative methods you can try.

Switch to a default WP theme

In some cases, there could be a conflict between a theme and a plugin, resulting in unexpected behavior.

Test this theory by switching to a default theme such as Twenty-Twenty. Turn of Website Application Firewall

If you are using a firewall such as Cloudflare, Sucuri, or a plugin, it may sometimes block legitimate requests as well.

The fastest way to confirm this is by deactivating the plugin or service.

Turn on Debugging in WP

WP comes with a built-in feature which allows you to store an error log. Note, that it’s not enabled by default.

If you wish to turn it on, add the following lines of code to the wp-config.php file:


This will make WP to keep an error log which you can access at any time by using the FTP client.

The log might be able to give you a clue about what might be causing the issue.

Contact Experts

If all else fails, it’s time to call the professionals. Contact your hosting company and they will check the problem for you.

We hope today’s article was useful in helping you figure out how to fix the invalid JSON error in WordPress.

Nadejda Milanova

Get 10% off your order


Enter UYD-772-MK5 at the checkout to get 10% off one-time tasks or any maintenance plan.

Get started