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
- Incorrect Site URL or Home URL Settings
- Permalinks Configuration Issues
- Theme or Plugin Conflicts
- Server Configuration Mistakes
- Mixed Content (HTTP/HTTPS Mismatch)
- Firewall or Security Plugin Blocking REST API
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.
- Go to Settings > General from your WordPress dashboard.
- 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.
- Navigate to Settings > Permalinks.
- 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.
- Temporarily switch your theme to a default one like Twenty Twenty-Three.
- Disable all plugins and try editing a post or page.
- 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.
- Go to Tools > Site Health.
- 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.
- Access your site files via FTP or File Manager.
- 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.
- Go to Plugins > Add New.
- Search for Classic Editor, install, and activate it.
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:
- Keep themes, plugins, and WordPress core up to date.
- Regularly test updates in a staging environment.
- Use trusted and well-reviewed plugins.
- Configure HTTPS properly across your entire website.
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)
-
What causes the “Invalid JSON” error in WordPress?
This error often emerges due to misaligned site URLs, plugin or theme conflicts, permalinks problems, or server-level configuration errors that hamper REST API communication. -
Is this error dangerous or harmful to my website?
No, it doesn’t harm the front end of your site. However, it will prevent you from saving or publishing content properly through the block editor. -
Can I fix this without technical knowledge?
Yes, many fixes—like checking site URLs or disabling plugins—require no coding skills. More complex issues, like editing .htaccess, may require some familiarity with site management. -
Will switching to the Classic Editor remove the error?
Not exactly. It bypasses the block editor that depends on JSON but doesn’t fix the malfunctioning REST API. It’s a temporary workaround, not a solution. -
Can server firewalls cause the Invalid JSON error?
Yes, some firewalls or security settings may block REST API requests resulting in an Invalid JSON error message.