Encountering the “Invalid JSON” error in WordPress can be a frustrating experience, especially when everything appears to be working fine. This error typically occurs when you’re trying to update a post or a page using the Gutenberg block editor. Instead of publishing or saving content, WordPress throws an error message indicating an invalid response in JSON format. Fortunately, this issue is resolvable with a few straightforward troubleshooting steps.

What Exactly Is the “Invalid JSON” Error?

WordPress uses JSON (JavaScript Object Notation) to communicate between the browser and the server, especially when you’re working in the block editor. When this communication breaks down—typically due to server misconfigurations, plugin conflicts, or URL structure problems—WordPress may respond with an “Invalid JSON” error.

The issue stems from WordPress not receiving the expected format of data during its REST API transactions. If the editor can’t fetch needed data or send your content using JSON, it responds with this error message.

Common Causes of the Invalid JSON Error

How to Fix the “Invalid JSON” Error in WordPress

Since there are multiple potential origins of this error, the resolution can differ. Follow these steps to identify and correct the problem efficiently.

1. Verify WordPress and Site URL Settings

First, ensure that your WordPress Address (URL) and Site Address (URL) match and are properly configured.

  1. Go to Settings > General from your WordPress dashboard.
  2. Check the WordPress Address (URL) and Site Address (URL). These should be exactly the same (both using either HTTP or HTTPS).

If your site uses HTTPS but either of these settings still shows HTTP, update them accordingly.

2. Fix Permalink Structure

Sometimes, saving your permalink settings can flush rewrite rules and solve the error.

  1. Navigate to Settings > Permalinks.
  2. Without changing anything, click Save Changes.

This process forces WordPress to rebuild the .htaccess file, correcting many underlying issues with link structures and URLs.

3. Check for Plugin or Theme Conflicts

One of the most common culprits of the “Invalid JSON” error is a plugin or theme conflict.

  1. Temporarily switch your theme to a default one like Twenty Twenty-Three.
  2. Disable all plugins and try editing a post or page.
  3. If the error disappears, one of your plugins is at fault. Re-enable plugins one-by-one to isolate the issue.

Once the problematic plugin or theme is identified, consider replacing it or contacting its developer for support.

4. REST API Debugging with Site Health Tool

WordPress includes a built-in tool that helps site admins analyze key components of their site’s health, including REST API usage.

  1. Go to Tools > Site Health.
  2. Check for any REST API errors under the “Status” tab.

If you see messages related to REST API failures or loopback requests, take note—these may shed light on the underlying JSON communication failure.

5. Inspect .htaccess File and Server Configuration

Sometimes server settings or a corrupted .htaccess file can disrupt WordPress communications.

  1. Access your site files via FTP or File Manager.
  2. Locate the root directory and open .htaccess.

Here’s the default WordPress .htaccess code. Replace yours if it’s corrupt:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

6. Address Mixed Content Issues

Serving your website over HTTPS but still referencing HTTP assets can cause JSON-related issues. Use plugins like Really Simple SSL to force HTTPS and resolve this.

After installation, activate the plugin and follow the setup process to convert all internal links and assets to use HTTPS uniformly.

7. Check Firewall and Security Plugins

Security settings can block important WordPress API functions. Some plugins and server-level firewalls prevent connections to admin-ajax.php or REST API endpoints.

Temporarily disable any security plugins and try updating your page again. If that works, you may need to whitelist admin URLs or REST routes in the plugin’s settings.

8. Use the Classic Editor Plugin (Temporary Fix)

If none of the above solutions work and you need a quick workaround, consider installing the Classic Editor plugin. While it doesn’t fix the error itself, it bypasses Gutenberg’s JSON dependency.

This reverts your editing environment back to TinyMCE, allowing you to continue working while you investigate a lasting solution.

Preventing the Invalid JSON Error in the Future

To minimize the chances of seeing this error again, consider the following:

Conclusion

The “Invalid JSON” error in WordPress is disruptive but certainly fixable. A systematic approach involving the verification of URLs, plugin conflicts, server configuration, and REST API diagnostics can usually identify and solve the problem. By understanding the causes and implementing lasting fixes, users can enjoy a smoother content creation experience in the block editor.

Frequently Asked Questions (FAQ)