Beginner's Guide for WordPress / Start your WordPress Blog in minutes

How to Fix the Invalid JSON Error in WordPress (Beginner’s Guide)

Are you trying to fix the invalid JSON error in WordPress?

This error appears when editing WordPress posts or pages on your website. You will see a message saying, ‘The response is not a valid JSON response’, and updating that page will fail.

In this article, we will show you how to easily fix the invalid JSON error in WordPress. We will also talk about why this error occurs and how to avoid it in the future.

JSON response is not valid error in WordPress

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

Failure to receive an expected response from the server causes the ‘Not a valid JSON response’ error in WordPress.

Basically, WordPress needs to communicate with the server while you are editing a blog post. It relies on getting responses from the web hosting server in the background. This response is usually in JSON format, which is used to quickly transport data using JavaScript.

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

Not valid JSON response error displayed in WordPress

This error could appear for a number of reasons. However, the most likely cause of it is incorrect URL settings in WordPress or broken permalinks.

That being said, let’s take a look at how to easily fix the invalid JSON error in WordPress.

Important: Please make a complete WordPress backup before making any big changes to your website. This allows you to easily restore your website to its previous state.

1. Check WordPress URLs in Settings

First, you need to make sure that your WordPress Address and Site Address settings are correct.

Simply go to Settings » General page. From here, you need to review the ‘WordPress Address (URL)’ and ‘Site Address (URL)’ fields.

WordPress URL settings

For most websites, this setting must have the same URL in both fields.

However, rarely, some users may have given WordPress its own directory and serve the website on a different address. In that case, they can have different URLs here.

However, if your Site Address is incorrect, then that will trigger the invalid JSON error in WordPress.

If you made any changes to the settings, then don’t forget to click on the ‘Save Changes’ button. You can now edit a blog post and see if adding any new blocks or saving that post triggers the ‘Not valid JSON response’ error.

If you are still seeing the error, then continue reading.

2. Fix WordPress Permalink Structure

WordPress comes with SEO friendly URL structure that allows you to use human-readable URLs for your posts and pages.

However, sometimes a user may mess up the permalink settings. This would make it impossible for the WordPress editor to get a valid JSON response and cause the error to appear.

To fix this, you need to simply visit the Settings » Permalinks page. From here, you must carefully review the permalink options.

Fix permalinks in WordPress

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

After that, go ahead and click on the ‘Save Changes’ button to store your settings.

You can now try editing a blog post or page to see if the error has disappeared. If it hasn’t, then you can try this next step.

3. Regenerate WordPress .htaccess File

The .htaccess file in WordPress is used as a configuration file to manage SEO-friendly URLs (permalinks).

Normally, WordPress can automatically regenerate and update the file. You can also trigger that update by simply clicking on the ‘Save Changes’ button at the bottom of Settings » Permalinks page.

However, sometimes it may not get updated or has incorrect settings. This will affect your WordPress permalinks and may also cause an invalid JSON response error.

To fix this, you will need to connect to your website using an FTP client or the file manager app in your WordPress hosting account dashboard.

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

Download .htaccess file as a backup

Tip: Can’t locate the .htaccess file? See this quick article on how to find .htaccess file.

After that, you need to edit the .htaccess file using an FTP client or the file manager app.

Edit .htaccess file

Once the file opens, you need to delete all the code inside 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

Don’t forget to save your changes and upload the file back to your website.

You can now visit your website and edit and post or page to see if you can reproduce the invalid JSON response error.

If you are still seeing the error, then there are a few more steps you can take.

4. View the REST API Debug Log

The invalid JSON response error can also mean that WordPress REST API on your website encountered an error.

The REST API is the set of techniques WordPress uses to communicate with the server as you work on your website.

You can see details of this error in the WordPress Site Health tool. Visit the Tools » Site Health page.

REST API issue in WordPress

From here, you may see an issue labeled ‘The REST API encountered an unexpected result’.

Clicking on it will show you more details, which may give you some clues about which plugin or third-party service is causing the issue.

If this doesn’t provide any clues, then you can move on to the next step.

5. Deactivate All WordPress Plugins

Occasionally, WordPress plugins may conflict with each other or the WordPress core software. This can result in unexpected behavior and could be a potential reason for the invalid JSON error.

Simply go to the Plugins » Installed Plugins page. From here, select all your WordPress plugins and then choose ‘Deactivate’ from the ‘Bulk Actions’ drop-down menu. Now, click the ‘Apply’ button to continue.

Deactivate all plugins

WordPress will now deactivate all your installed plugins.

You can now try again to reproduce the error. If the error disappears, then this means one of the plugins installed on your website was causing it.

To figure out which plugin is the problem, you just need to activate them one by one and try to reproduce the error. Repeat this until you find the culprit.

After that, you can reach out to the plugin author for support or find an alternative plugin.

6. Temporarily Switch to the Classic Editor

If all the above steps fail, then you can temporarily switch to the Classic Editor for WordPress.

This older version of the WordPress editor uses a simpler text editor and doesn’t rely heavily on REST API to get JSON responses.

To use it, you need to install and activate the Classic Editor plugin. For more details, see our step-by-step guide on how to install a WordPress plugin.

The plugin works out of the box, and it will disable the Gutenberg editor upon activation.

You can now continue working on your website and get back to troubleshooting later.

7. Further Troubleshooting

A number of things can block WordPress REST API or make it return an invalid JSON response. We have addressed the most likely culprits above, but if that didn’t fix it for you, then here are some more steps that you can try.

Switching to a Default WordPress Theme

Sometimes a conflict between your WordPress theme and a plugin or the WordPress core may result in unexpected behavior.

You can test this, by simply switching to a default WordPress theme like TwentyTwentyOne or Twenty-TwentyTwo.

Temporarily Turn Off Website Application Firewall

If you are using a WordPress firewall like Sucuri, Cloudflare, or a plugin, then it may sometimes block legitimate requests too.

The easiest way to figure this out is by temporarily disabling your WordPress firewall plugin or service.

Some application-level WordPress firewalls can be disabled by simply deactivating the plugin. For DNS-level firewalls like Sucuri and Cloudflare, you can disable them from your account dashboard.

Turn On Debugging in WordPress

WordPress comes with a built-in feature that allows you to keep a log of errors. However, it is not enabled by default.

To turn it on, you need to add the following code to your wp-config.php file:

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

After that, WordPress will keep a log of all errors in a debug.log file located inside the /wp-content/ folder. You can access this file by using an FTP client.

The error log may provide you with a clue about what may be causing the invalid JSON error on your website. For more details, see our guide on setting up WordPress error logs and using them for debugging errors.

Seek Expert Help

Finally, if all else fails, then this could be due to a misconfiguration on your WordPress hosting server. Most reliable WordPress hosting companies are able to help users with common WordPress issues.

Simply reach out to them via live chat or support ticket, and they may be able to help you fix it.

We hope this article helped you learn how to fix the invalid JSON error in WordPress. You may also want to see our complete handbook of the most common WordPress errors and how to fix them, along with our top picks for the best email marketing services for small business.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit – a collection of WordPress related products and resources that every professional should have!

Reader Interactions

30 CommentsLeave a Reply

  1. In my case, the issue was the uploaded image dimensions. Anything above 2000 pixels was causing the error.

    • Thank you for sharing what was the cause of the error for you. If you did not try it, you should be able to increase the maximum upload limit for your site to prevent image sizes being an issue in the future.


  2. Thank you, after installing an SSL some pages were bringing up the 404. This helped me realize I needed to change http:// to https:// in General settings and it fixed the problem.

  3. Thank you for the detailed instructions on how to fix this json error in wordpress. I tried all above ideas to fix. None of them worked. The solution I found was turning off mod security in hosting control panel (cpanel).

  4. One can also be using a deprecated or non-existing WordPress function.

    This has happened to me twice, both times when saving a page in the editor. I systematically commented out functions in functions.php, and eventually, the error stopped. The offending function was something I scrapped off someone’s blog without really understanding it. So, be careful.

    • Thank you for sharing this for anyone looking for the root of the issue on their site!


  5. I was having this issue and narrowed it to to trying to save anything containing the content “delete it.”

    I haven’t dug in to verify this, but I’m pretty sure Apache mod_security is triggering on that content, thinking it’s part of a sql injection attack and blocking the request.

    I just reworded my content to avoid that phrase. If that’s not an option, you can disable mod_security or write an exception.

    • Thanks for sharing another possible reason why users could run into this issue!


  6. I had another, stupid cause: mod_rewrite was not enabled in apache configuration. enabling it fixed the error.

  7. If you are using IIS, you need to make sure “OPTIONS” is permitted as one of your “HTTP VERBS”.

    Launch Internet Information Service (IIS) Manager at Windows Start > All Programs > Windows Administrative Tools.
    In IIS Manager, expand SERVERNAME > Sites > click > Handler Mappings (under IIS).
    Find the handler which is used by the website and double-click on it.
    Double-click on your PHP handler (there may be more than one listed)
    Click Request Restrictions….
    Switch to the Verbs tab.
    Add required verbs in to the verbs field, for example:
    Click OK to apply the changes in both windows.

    • Thank you for sharing this for those using IIS, for most users we would normally recommend reaching out to your hosting provider for this level of modification :)


  8. My site error:
    Updating failed. The response is not a valid JSON response
    I solved my error from this instructions;
    Fix WordPress Permalink Structure
    Thank you this helping.

  9. Hi, thank you for this detailed write up, I’ve read through it and find it so detailed and insightful.

    However, I have an unanswered question which is this:
    Could this error be as a result of invalid or expired SSL certificate?

    • That can cause different errors but this specific error would not normally be caused by an SSL certificate.


Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.