How to Fix the Invalid JSON Error in WordPress

WordPress is a popular platform for users across the globe as it is pretty easy to use and offers the best services. It is one of the most preferred website-building platforms for users worldwide, whether beginners or experts.  

However, you might encounter a few errors while working with it. It could be caused due to many reasons, some on your end and some from the other end of the service, which might greatly annoy you, and one such error is the invalid JSON Error. 

When you are working with your content and posting on WordPress, you might encounter an error that says, ‘The response is not a valid JSON response’, which must be removed. We will look at what it actually is, what causes it, and how to resolve it in this article.  

In this article, we will learn how to fix the Invalid JSON error.

What causes the ‘Not a Valid JSON Response’ Error in WordPress?

Before we start working on how to fix it, we must first know what causes the ‘Not a valid JSON response’ error on WordPress. This usually occurs when you are working with your posts on WordPress

When the server fails to send an expected response, the error ‘Not a valid JSON response’ occurs. 

While you work or edit your post and pages on WordPress, it communicates with the servers. This response depends on the web hosting server that you have hired. The response should be in JSON format, which helps to transport data using JavaScript. 

And when the response is not in the JSON format, you will encounter the ‘Not a valid JSON response’ error. This error could also have occurred due to the wrong URL settings in WordPress or broken permalinks

Before you follow any of these methods, ensure a backup is ready. 

How to Fix The “Updating Failed. The Response is Not a Valid JSON Response” Error in WordPress

Let us now look at some of the easiest ways to fix this error on WordPress. 

Check the URL Settings of the WordPress Site

As we mentioned earlier, the ‘not a valid JSON’ error might have occurred due to a wrong URL setting. Let us now learn how to fix it. 

Check the URL Settings of the WordPress Site
  • Generally, in both of these, the URLs must be the same.
  • Sometimes, users might have provided WordPress with its directory and might serve the website on a separate address. 
  • If the URL is incoherent, which might have caused the JSON error, correct it and click on the ‘Save Changes’ button. 

Now you can go back to working on your posts.

Fix the WordPress Permalink Structure

WordPress has an SEO-based URL structure which helps it create URLs that are readable to humans. However, when users mess it up, it might become impossible to get a response in the JSON format. To fix it:

  • Click on ‘Settings’ and select ‘Permalinks’.
Fix the WordPress Permalink Structure
  • Check which setting has been wrong and put it back to the default format. 
  • Select ‘Save Changes’, and you are done!

Regenerate WordPress .htaccess File

To fix the JSON error on WordPress through this method, you might want to connect your website using an FTP client or file manager app in your WordPress hosting dashboard.

  • Once the connection has been made, find the .htaccess file in the root folder of your website and download it as a backup.
Regenerate WordPress .htaccess File
  • Now edit the .htaccess file through the FTP client or the file manager app.
  • Once inside it, delete all the code and paste these:
Regenerate WordPress .htaccess File

And save changes to get back to work. 

Check the Themes and Plugins

Sometimes the plugin and theme combinations cause problems, and to get rid of them, you might want to delete them. Before doing any of it, you must have a backup, so you do not lose any of your data. 

  • Go to ‘Appearance’ and then ‘Themes’ and activate the default WordPress theme. Check if the error has been resolved. 
  • If the error has been fixed, delete the theme and, if not, get it back. 
  • Go to ‘Installed Plugins’, select all of them and deactivate.
Check the Themes and Plugins
  • Now try reactivating plugins, and as you do so, check if the error has regenerated every time. 
  • When it has, deactivate the plugin that caused it. 

Switch to Classic Editor Temporarily

Sometimes working with a new editor might have caused the JSON error. And switching to the classic editor might work as a temporary cure and is unsuitable for the long run. 

Switch to the classic editor, edit the post and then switch back to the Gutenberg editor. Let us now see how it’s done. 

  • Go to ‘Plugins’ and ‘Add new’ through the WordPress menu, then look for the classic editor and install it. 
  • Once installed, edit your post or publish it.

Now, uninstall the classic editor and go back to the Gutenberg editor. 

Read: Fix the Error too Many Redirects on WordPress cPanel

Check the Site Health

  • To check the site’s health, go to ‘Tools’ and then to ‘Site Health’. 
  • Check if WordPress ‘REST API’ on your website found an error.
  • To do the same, look for ‘The REST API encountered an unexpected result.’
  • Now solve the issue which might fix the JSON error.
Check the Site Health

Disable the Security Firewall

Sometimes when you use a firewall to secure your WordPress websites, it might cause problems with the editor, resulting in the JSON error. And disabling it might help. 

You can either disable the firewall yourself or ask your host to do it. If in doing so, the error has gone, you might want to replace your current firewall

Use Debugging in WordPress

  • To know what is causing the JSON error, you must look into the bugs in your WordPress site. To do so, turn on the plugin of WordPress that helps you keep a log of errors. 
  • Enter the following code in the ‘wp-config.php’ file. To turn it on:
Use Debugging in WordPress
  • Now look for the ‘debug.log’ file in the ‘/wp-content/’ folder through the FTP client where WordPress stores all the errors
  • Here you can look into what code is causing the error. 
Read: How to Login into DirectAdmin 

Upload Media Files Through the Media Library

  • If you are encountering errors while uploading files through the Block editor, you could choose to upload files directly through the Media Library.
Upload Media Files Through the Media Library
  • While adding an image block, select the ‘Media Library’ option.  
Upload Media Files
  • Choose the file to be uploaded and click on ‘Select’. And you’re done. 
Read More: How To Clear Cache for All Major Browsers

Look for Expert Help

Not everyone’s an expert or has to be. Many users who opt for WordPress are beginners and are looking for ease. And in such situations where an error occurs, their ease and peace might get disturbed. 

Therefore, if you are unable to perform the above solutions or if they do not work, the final option is to seek an expert’s help who is well versed in this field.

As with an expert, you will have the least chances of loss as they know what they are doing. It might cost you some money, but it would be worth the service. 

Conclusion

This article taught us numerous ways to fix the invalid JSON error in WordPress. Most of these methods are beginner-friendly, so you can try them out before seeking an expert’s help as you can save time and money. Since this error comes in between you and your online presence goals, you must rectify it. 

However, if you do not have any idea how to go about these issues, an expert’s help would be great as they will know how to go about it and what is causing the error. So make your decision and thrive on WordPress.

Leave A Comment