Fix "SyntaxError: Unexpected token < in JSON at position 0"
Developer guide and instant terminal command to diagnose and solve this error.
Why Does This Error Happen?
Your client-side code called response.json(), but the backend API server returned an HTML error page (like a 404, 500, or Nginx error page starting with "<!DOCTYPE html>").
Instant Terminal One-Liner Fixes
Comprehensive Step-by-Step Resolution
- 1Check the HTTP response status code before parsing ("if (!res.ok) throw new Error(...)").
- 2Inspect the raw text using "await res.text()" to see the actual HTML server error message.
- 3Ensure the API endpoint URL path is correct and backend server is running.
Troubleshoot using the JSON Validator & Formatter
Use our client-side utility with zero server upload for instant debugging.
Frequently Asked Questions
Frequently Asked Questions
Everything you need to know regarding specifications, syntax, and security best practices.
Your client-side code called response.json(), but the backend API server returned an HTML error page (like a 404, 500, or Nginx error page starting with "<!DOCTYPE html>").
Related Developer Errors
Fix "CORS Policy: No Access-Control-Allow-Origin header is present"
Fix "ReferenceError: window is not defined" in Next.js & React SSR
Fix "TypeError: Cannot read properties of undefined (reading 'xyz')"
Fix "npm ERR! code ERESOLVE unable to resolve dependency tree"