In the modern era of the Block Editor and Gutenberg, the “The response is not a valid JSON response” error has become one of the most common frustrations for WordPress users. It basically means that when you save a post, WordPress sends a request to its REST API, but the server responds with something “ugly” (like a PHP warning or an HTML error page) instead of clean JSON data. At CODE TOT, we’ve debugged this on hundreds of high-traffic sites.
Professional Insight: This error isn’t actually about JSON. It’s a “catch-all” message for any server error that happens during a REST API call. The first thing you should do is check your Browser Console (F12) for the “Network” tab—it will show you the *actual* error being returned by the server.
1. The Permalink / .htaccess Collision
The REST API relies on “Pretty Permalinks” to work correctly. If your .htaccess file is corrupted or missing, the API endpoints will return a 404 error in HTML format, which triggers the “invalid JSON” message. Simply go to **Settings > Permalinks** and hit “Save Changes” to refresh your site’s rules.
2. Silent PHP Warnings & Errors
If you have WP_DEBUG_DISPLAY enabled on a production server, a single PHP notice (like a “Deprecated” warning from an old plugin) will be printed at the top of the REST API response. This “pollutes” the JSON and makes it invalid. **Always disable display of errors** on live sites:
# In wp-config.php
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );3. Firewall Interference (Cloudflare & ModSecurity)
Modern WAFs often block large chunks of text being sent via a POST request—which is exactly what the Block Editor does when you save a long post. If **ModSecurity** on your RunCloud server sees a specific keyword or a long string it doesn’t like, it might block the request with a 403 error. Check your firewall logs if the error only happens on long posts.
4. Site URL Mismatch (HTTPS vs HTTP)
If your WordPress Address (URL) is set to http:// but you are accessing the site via https://, the editor will try to make an API call to the insecure version. Most browsers will block this “mixed content” request, resulting in an invalid response. Ensure both URLs in **Settings > General** use the https:// protocol.
Conclusion
The “Invalid JSON” error is a messenger of a deeper problem. By checking your permalinks, disabling error display, and verifying your HTTPS settings, you can clear the path for the REST API to function properly. For persistent API issues on headless WordPress builds, consult our REST API Development Team.


