Skip to content
WordPress

WordPress Invalid JSON Response: Diagnosing the Error

Learn how to fix the WordPress JSON response error by diagnosing REST API failures, server misconfiguration, and invalid output issues.

WordPress Invalid JSON Response: Diagnosing the Error

The WordPress JSON response error is most commonly encountered in the block editor, where it typically surfaces as an “Updating failed” or “Publishing failed” notice — or as an editor that simply refuses to save changes. The underlying cause is that the block editor sends a request to the WordPress REST API and receives a response that is not valid JSON. Because the editor expects structured JSON data and instead gets something else — an HTML error page, a redirect, extra output before the JSON, or nothing at all — it reports the WordPress JSON response error and fails to complete the operation. I have seen this error on sites of all sizes and ages, and the causes are frustratingly varied, which is why I have arranged this guide around the specific diagnostic that confirms which cause is active on your site before you start applying fixes. You’ll find the complete rundown in our WordPress Errors Complete Guide.

First diagnostic step: Visit yoursite.com/wp-json/ directly in your browser. If this URL returns a JSON structure (a large block of text starting with a curly brace), the REST API itself is working and the WordPress JSON response error is caused by output interference on specific operations. If the URL returns a 404, a redirect, or an HTML page, the REST API routing has a problem and the permalink fix below is your starting point.

What the WordPress JSON Response Error Is Telling You

JSON (JavaScript Object Notation) is the data format that WordPress’s REST API uses for all communication between the block editor and the WordPress backend. When the block editor saves a post, it sends a REST API request and expects a JSON response confirming success. The WordPress JSON response error occurs when the response that comes back from the server is not valid JSON — meaning something has either prepended extra output to the response, replaced the response entirely with an HTML error page, or the response is empty. All of these produce the same WordPress JSON response error from the block editor’s perspective.

The most important thing to understand about the WordPress JSON response error is that it is almost never caused by the JSON format itself. WordPress’s core REST API response code is well-tested and produces valid JSON consistently. The WordPress JSON response error almost always means something outside of the REST API response code is interfering with the output — a plugin that outputs text before WordPress sends its headers, a theme function that echoes something unexpectedly during a REST API request, a PHP error that gets printed into the response body, or a server configuration that sends its own error response instead of passing the request through to WordPress.

PHP warnings and notices are the most common single cause of the WordPress JSON response error in production environments. When WordPress is configured to display PHP errors (which should never happen on a live site), any PHP warning triggered during a REST API request gets prepended to the JSON response. The response starts with the PHP warning text — which is not JSON — and the block editor reports the WordPress JSON response error because the response fails JSON validation at the very first character. Even a single PHP notice is sufficient to corrupt the JSON response and produce this error.

Fix the WordPress JSON Response Error With Permalink Regeneration

Permalink regeneration is the single fastest fix to try for the WordPress JSON response error, and it resolves a large proportion of cases because REST API routing depends on the same rewrite rules that control permalink URL resolution. When these rules are stale, incomplete, or corrupted — often after a plugin change, a WordPress update, or a migration — REST API requests route incorrectly and the WordPress JSON response error results.

  1. Log in to the WordPress dashboard
  2. Go to Settings → Permalinks
  3. Click Save Changes without modifying any setting — this regenerates the rewrite rules in the database and rewrites the .htaccess file
  4. Open a new browser tab and navigate to yoursite.com/wp-json/ to confirm the REST API returns a JSON response
  5. Return to the block editor and test whether post saving now works without the WordPress JSON response error
  6. If the error persists, try switching to a different permalink structure (e.g. from Post name to Day and name), saving, then switching back to Post name and saving again — this forces a more complete rewrite rule regeneration

The permalink fix also addresses a specific variant of the WordPress JSON response error caused by a missing .htaccess file. Without .htaccess, WordPress’s pretty URLs — including the /wp-json/ REST API base — return 404 errors rather than being processed by WordPress. Saving permalink settings recreates the .htaccess file if it was deleted or if the file manager does not show it (hidden files start with a dot and are invisible in some file managers by default).

Plugin Conflicts and PHP Output Causing the WordPress JSON Response Error

Plugins that produce any output during a REST API request corrupt the JSON response and trigger the WordPress JSON response error. This can happen explicitly — a plugin using echo or print in code that runs on every request including REST API requests — or implicitly through PHP warnings and notices that the plugin’s code generates. The block editor’s “Updating failed” message with the WordPress JSON response error in this context often appears immediately after installing or updating a plugin, which makes the timing a strong diagnostic clue.

The fastest test for plugin-caused WordPress JSON response error is checking the raw REST API response. With browser developer tools open (F12 → Network tab), attempt to save a post in the block editor. Find the failed POST request to /wp-json/wp/v2/posts/ in the network list and look at the Response body. If the response starts with any text before the opening curly brace — a PHP warning, an HTML fragment, a plugin’s debug output — that pre-JSON output is causing the WordPress JSON response error. The content of that text identifies which plugin or theme function is generating the unwanted output.

Deactivating plugins one at a time and testing the block editor after each deactivation identifies the specific plugin responsible for the WordPress JSON response error. Priority candidates: recently installed or updated plugins, debugging or logging plugins that may have output functions, plugins that add hooks to init or plugins_loaded actions without checking whether the current request is a REST API request. After identifying the culprit, check whether the plugin has pending updates that might address the output issue, or contact the plugin developer with the specific unwanted output content — that content is an unambiguous bug report.

Debug Mode and PHP Error Output Behind the WordPress JSON Response Error

If WordPress debug mode is enabled on a live site — specifically if WP_DEBUG_DISPLAY is set to true — any PHP error, warning, or notice generated during a REST API request is printed into the response body, producing the WordPress JSON response error for the block editor. This is a particularly common cause on sites that were set up by a developer who enabled debug mode during setup and never disabled it before handing the site to the client.

Check wp-config.php for these three debug settings:

define( 'WP_DEBUG', true );           // Enable or disable PHP error reporting
define( 'WP_DEBUG_LOG', true );       // Write errors to wp-content/debug.log (safe on live sites)
define( 'WP_DEBUG_DISPLAY', false );  // Display errors in browser (MUST be false on live sites)

On a live production site, WP_DEBUG_DISPLAY must always be false. WP_DEBUG can be true if you want errors logged to the debug log, but WP_DEBUG_DISPLAY being true — or absent when WP_DEBUG is true, since WordPress defaults to displaying errors when debugging is enabled — causes PHP errors to appear in REST API responses and produce the WordPress JSON response error. Setting WP_DEBUG_DISPLAY to false keeps error logging active while preventing errors from corrupting REST API JSON responses. After making this change, test the block editor again — if PHP output was the cause, the WordPress JSON response error clears immediately.

Server Configuration and Authentication Issues

Some hosting server configurations produce the WordPress JSON response error at the infrastructure level rather than through WordPress code. A server-level Web Application Firewall rule that modifies REST API responses, a caching layer that serves cached HTML pages in response to REST API requests, or a CDN that intercepts /wp-json/ URLs before they reach WordPress can all produce non-JSON responses that trigger the WordPress JSON response error in the block editor.

Caching plugins configured to cache logged-in user requests are a specific cause worth checking. If a caching plugin serves a cached HTML page in response to a REST API POST request (which should never be cached), the block editor receives HTML instead of JSON and reports the WordPress JSON response error. Check your caching plugin’s configuration for settings related to REST API requests and logged-in user caching — REST API POST requests should be excluded from the cache in every caching plugin’s configuration, but not all plugins do this correctly by default.

Authentication nonce failures produce a specific variant of the WordPress JSON response error where the REST API returns a valid JSON response but with a 403 status and an authentication error message. This happens when the nonce included in the block editor’s REST API request is invalid or expired — usually because a security plugin has changed the nonce salt, a session has been invalidated, or a misconfigured authentication plugin is rejecting the cookie-based authentication that the block editor uses. Logging out and logging back in to WordPress refreshes the authentication context and resolves nonce-expiry-based WordPress JSON response error instances in most cases.

Our guide on fixing the WordPress REST API error covers the REST API routing and security plugin blocking issues that share several causes with the WordPress JSON response error — both errors involve REST API communication failures, just at different layers. Our guide on how to enable WordPress debug mode safely covers the correct debug configuration that enables logging without causing the output contamination that produces the WordPress JSON response error in production environments. The JSONLint validator is useful for pasting the raw REST API response from your browser’s network inspector to confirm exactly what is malformed in the response causing the WordPress JSON response error — it highlights the first invalid character and the expected format at that position. See also WordPress Publish Error for a related case.

Nikolas Lamprou

Nikolas Lamprou (MSc; GCFR, SC-200, Security+) has been working with computers professionally since 2009 — starting with web development and e-commerce, and moving into cybersecurity over the years. Based in Greece, he brings over 15 years of real-world IT experience to SolveTechToday, where he writes about Windows fixes, software reviews, security tools, and AI applications. His goal is straightforward: cut through the noise and give readers clear, honest guidance on the tech decisions that matter.

Stay Ahead

Fix your next problem before it starts

Get the week's best Windows fixes, software picks, and security guides delivered straight to your inbox. No noise, just solutions.

Press ESC to close · Try "Windows 11" or "Chrome"