How to Resolve an Invalid JSON Error in WordPress (A Beginner’s Guide)

Are you attempting to resolve the WordPress incorrect JSON error?

When editing WordPress posts or pages on your website, this error arises. The notice ‘The response is not a valid JSON response’ will appear, and changing that page will fail.

We’ll teach you how to simply fix the incorrect JSON error in WordPress in this article. We’ll also discuss why this mistake occurs and how to avoid it in the future.

What causes the WordPress ‘Not a Valid JSON Response’ Error?
The ‘Not a valid JSON response’ problem in WordPress is caused by a failure to receive an expected response from the server.

WordPress, in essence, needs to communicate with the server when you are editing a blog post. It relies on background answers from the web hosting server. This response is often in JSON format, which is used to rapidly transmit data using JavaScript.

If WordPress fails to get the response for whatever reason, or if the response is not in JSON format, you will see the ‘Not a valid JSON response’ error.

This error could occur for a variety of reasons. The most likely problem, however, is wrong URL settings in WordPress or broken permalinks.

That being said, let’s look at how to quickly resolve the invalid JSON problem in WordPress.

Important: Before making any major changes to your website, always create a full WordPress backup. This makes it simple to return your website to its prior state.

Contents

1. Go to Settings and look at the WordPress URLs.

To begin, double-check that your WordPress Address and Site Address settings are accurate.

Simply go to the General page under Settings. Review the WordPress Address (URL) and Site Address (URL) fields from here.

This parameter must have the same URL in both fields for most websites.

Some users, on the other hand, may have given WordPress its own directory and served the website from a different URL. They can have separate URLs in this situation.

However, if your Site Address is incorrect, WordPress will display an invalid JSON error.

If you make any changes to the settings, don’t forget to save them by clicking the Save Changes button. You can now update a blog post to see if adding additional blocks or saving it causes the ‘Not valid JSON response’ problem to appear.

Continue reading if you’re still getting the error.

2. Repair the WordPress Permalink Structure

WordPress includes an SEO-friendly URL structure that lets you use human-readable URLs for your posts and pages.

However, a user may occasionally tamper with the permalinks settings. This would make it difficult for the WordPress editor to receive a proper JSON response, resulting in the error.

To resolve this, simply navigate to the Settings » Permalinks page. From here, you must carefully consider your permalink alternatives.

If you are unsure whether you are using the correct settings, simply select one of the various default formats.

Following that, click the Save Changes button to save your selections.

You can now attempt to modify a blog post or page to see if the problem has been removed. If it hasn’t, proceed to the next step.

3. WordPress .htaccess File Regeneration

In WordPress, the .htaccess file is utilized as a configuration file to govern SEO-friendly URLs (permalinks).

WordPress can normally renew and update it automatically. You may also force the update by clicking the Save Changes button at the bottom of the Settings » Permalinks page.

However, it may not always be updated or may have the wrong settings. This would have an impact on your WordPress permalinks and could result in an invalid JSON response issue.

To resolve this, use an FTP client or the file management software in your WordPress hosting account dashboard to connect to your website.

Once connected, locate the .htaccess file in the root folder of your website and download it to your PC as a backup.

Then, using an FTP client or a file manager tool, modify the .htaccess file.

Once the file has been opened, you must erase all of the code contained within it and replace it with the following 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

Remember to save your changes and re-upload the file to your website.

You can now go to your website and try to reproduce the incorrect JSON response error by editing a post or page.

If the issue persists, there are a few additional steps you can do.

4. Rest API Debug Log

The incorrect JSON response error could potentially indicate that your website’s WordPress REST API has encountered a problem.

The REST API is a set of strategies used by WordPress to communicate with the server when working on your website.

The WordPress Site Health tool can show you more information about this problem. Go to the Site Health page under Tools.

You could view an issue titled ‘The REST API encountered an unexpected result’ from here.

By clicking on it, you’ll get more information that may help you figure out whether a plugin or third-party service is causing the problem.

If this doesn’t give you any information, you can proceed to the following step.

5. Turn off all WordPress plugins.

WordPress plugins can occasionally clash with each other or with the WordPress core. This could cause unexpected behavior and be one of the causes of the invalid JSON error.

To do so, navigate to Plugins > Installed Plugins. Choose ‘Deactivate’ from the Bulk Actions drop-down box after selecting all of your WordPress plugins. To proceed, click the Apply button.

All of your installed plugins will now be deactivated by WordPress.

You can now try to reproduce the issue once more. If the error goes away, it was probably caused by one of the plugins you have installed on your website.

To figure out which plugin is causing the problem, try activating each one separately and then reproducing the error. Rep until you’ve found the culprit.

After that, you can either contact the plugin’s author for assistance or look for a different plugin.

6. Switch to the Classic Editor for the time being.

If all of the preceding procedures fail, you can switch to the Classic Editor for WordPress.

This older version of the WordPress editor employs a simpler text editor and does not significantly rely on the REST API to obtain JSON responses.

You must install and activate the Classic Editor plugin before you can use it. See our step-by-step guide on how to install a WordPress plugin for additional information.

The plugin works right away, and when used, it disables the Gutenberg editor.

You can now work on your website and return to troubleshooting later.

7. Additional Troubleshooting

The WordPress REST API can be blocked or deliver an invalid JSON response for a variety of reasons. We’ve already addressed the most likely causes, but if those don’t work, there are a few more things you can try.

Using the WordPress Default Theme

Unexpected behavior can sometimes be caused by a conflict between your WordPress theme and a plugin or the WordPress core.

Simply switch to a default WordPress theme like TwentyTwentyOne or Twenty-Twenty to try this.

Turn off the Website Application Firewall for the time being.

If you use a WordPress firewall, such as Sucuri, Cloudflare, or a plugin, it is conceivable that valid requests will be blocked as well.

The simplest approach to find this out is to disable your WordPress firewall plugin or service momentarily.

Some WordPress application-level firewalls can be turned off by simply deactivating the plugin. DNS level firewalls, such as Sucuri and Cloudflare, can be disabled from your account dashboard.

In WordPress, enable debugging.

WordPress has a function that allows you to keep track of errors. It is not, however, activated by default.

You must add the following code to your wp-config.php file to enable it:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );

Following that, WordPress will keep a log of all issues in the /wp-content/ folder’s debug.log file. Using an FTP client, you can access this file.

The error log might help you figure out what’s causing your website’s invalid JSON problem. See our guide to setting up WordPress error logs and utilizing them to debug faults for more information.

Seek professional assistance.

Finally, if all else fails, it could be due to a WordPress hosting server misconfiguration. The majority of reputable WordPress hosting companies can assist users with such basic WordPress issues.

Simply contact them using live chat or a support ticket, and they may be able to assist you.

We hope that this article has given you some insight into how to resolve the incorrect JSON error in WordPress. In the comments section below, let us know which approach worked best for you.

Leave a Reply