contact_mailContact Form 7apiREST APIerrorPHP errorinfoajaxcodejsonwarningvalidationlabelCommonwarningModerate

Contact Form 7: Invalid JSON response

Contact Form 7 sends an AJAX request to a REST endpoint. The endpoint must return a clean JSON object. When the response contains any other data, the browser reports an invalid JSON error.

Output contamination is a frequent cause. Any echo, print, var_dump, PHP notice or warning that appears before the JSON payload corrupts the response. The first character of the output becomes HTML, which breaks the JSON parser.

Caching plugins often serve a stored HTML page for the REST URL. They may also inject extra markup into the response. The result is an HTML document instead of JSON.

Security and firewall plugins can block the REST request or prepend an access‑denied message. The request then returns a 403 or 404 page, which the form treats as invalid JSON.

Outdated or broken Contact Form 7 add‑ons hook into the JSON echo filter. They may return malformed data or abort the request. The form never receives the expected success payload.

Incorrect rewrite rules, server‑level compression, mixed HTTP/HTTPS, or wrong site URL settings also prevent the endpoint from delivering proper JSON. The endpoint may return a 500 error or an empty response.

Symptoms

[dashicons-warning]
Spinner never stops
The loading indicator continues after you press submit.
[dashicons-warning]
Console JSON error
Browser console shows SyntaxError: Unexpected token < in JSON at position 0.
[dashicons-warning]
HTML response
Network tab shows an HTML page instead of a JSON object.
[dashicons-warning]
Admin notice
WordPress displays “The response is not a valid JSON response.”

Common Causes

Output contamination
Echo, var_dump or PHP notices output before the JSON payload.
Caching plugins
Cache serves a stored HTML page for the REST endpoint.
Security/firewall plugins
Block or prepend HTML to the REST request, causing 403/404 pages.
Broken CF7 add‑ons
Add‑ons modify the JSON echo filter and return malformed data.
Rewrite or URL mismatch
Incorrect .htaccess, NGINX rules or wrong siteurl/home settings lead to 404 errors.
Need this fixed right now?

Don't waste your day debugging. Our experts can Fix your issues in under 2 hours.*

Success Rate

100% Guaranteed

Starting from

$35 /hour
99+

Trusted by Business Owners

“I spent 3 days trying to fix the Elementor loading loop. These guys fixed it in 20 minutes. Lifesavers!”

— Sarah J., Web Designer

Related Issues

contact_mail
Contact Form 7: REST API request failed: 503 Service Unavailable
A 503 Service Unavailable response stops Contact Form 7 from sending data...
apiREST APIerror503descriptioncontact-form-7
contact_mail
Contact Form 7: REST API request failed: 429 Too Many Requests

The form tries to send data through the WordPress REST API. The...

apiREST APIerrorerrorsecurityfirewalldescriptioncontact-form-7settingsserver_configuration
contact_mail
Contact Form 7: REST API request failed: 401 Unauthorized

The form tries to send data via the WordPress REST API. The...

apiREST APIadmin_panel_settingspermissionsdescriptioncontact-form-7lock401
contact_mail
Contact Form 7: File upload error: temporary directory missing

The error appears when Contact Form 7 cannot locate a writable temporary...

codePHPcloud_offupload erroradmin_panel_settingspermissionsdescriptiontemporary filedescriptioncontact-form-7
contact_mail
Contact Form 7: Mail (2) sending failed: PHP mail() function disabled

Contact Form 7 reports a failure for Mail (2) when the PHP...

codePHPerrorerrordescriptioncontact-form-7mailMailsettingsserver_configuration
contact_mail
Contact Form 7: Mail (2) sending failed: SSL certificate verification failed

Contact Form 7 reports a failure when trying to send the secondary...

errorerrorlocksslcodecURLdescriptioncontact-form-7