The first character being '<' usually indicates that the expected JSON response is HTML. This could be due to a wrong endpoint, a 404/500 error page, a login redirect, a PHP warning, a WAF challenge, or a WISECP theme output being attempted to be parsed like JSON by response.json().
SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
Unexpected token < in JSON at position 0
JSON.parse: unexpected character at line 1 column 1The first character being '<' usually indicates that the expected JSON response is HTML. This could be due to a wrong endpoint, a 404/500 error page, a login redirect, a PHP warning, a WAF challenge, or a WISECP theme output being attempted to be parsed like JSON by response.json().
A SyntaxError may stop all subsequent scripts; First resolve the first red record in the Console.
Determine whether the error is source or build with Source map, pretty print and Network URL.
Reduce the issue to a small area with node --check, ESLint, TypeScript or JSON validator.
Check the PHP render, API body, CDN cache and module loader result in the production answer.
Do not hide JSON errors using try/catch and use the HTML response as normal data.
Meaning: Response starts with HTML instead of JSON.
Possible cause: 404, 500, login, or theme page.
Meaning: Full HTML document is sent to JSON parser.
Possible cause: Incorrect endpoint or redirection.
Meaning: PHP warning/parse error text may get mixed up with JSON.
Possible cause: display_errors is open or fatal error.
Meaning: Access denied text response was returned.
Possible cause: Authority, session or CSRF issue.
Meaning: The server is sending HTML content type instead of JSON.
Possible cause: Route/handler wrong.
Meaning: API call was redirected to the login page.
Possible cause: Session duration or auth middleware.
Meaning: WAF bot validation page returned.
Possible cause: Rate limit or security rule.
Meaning: Proxy generates custom error page.
Possible cause: Nginx/Apache upstream error.
No records matching this expression were found.
curl -i https://example.com/api/dataHTTP status, Content-Type and response are shown together.
curl -sIL https://example.com/api/data | grep -iE '^HTTP|^location:|^content-type:'This shows redirecting to the login or error page.
curl -s https://example.com/api/data | python3 -m json.toolResponse is not valid JSON, gives parsing error.
curl -sL https://example.com/api/data | head -c 300Response starts with HTML, PHP error message or JSON.
tail -n 100 /var/log/php-fpm/error.log 2>/dev/null || tail -n 100 /var/log/php8.3-fpm.logDisplays PHP errors that occurred during the API call.
fetch('/api/data').then(async r => ({status:r.status,type:r.headers.get('content-type'),url:r.url,body:await r.text()})).then(console.log)Before parsing, show status, content type, final URL, and body.
const data = await response.json();const metin = await response.text();
if (!response.ok) throw new Error(`${response.status}: ${metin.slice(0,200)}`);
const veri = JSON.parse(metin);echo json_encode($veri);header('Content-Type: application/json; charset=utf-8');
echo json_encode($veri, JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR);http_response_code(500);
echo '<h1>Error</h1>';http_response_code(500);
header('Content-Type: application/json; charset=utf-8');
echo json_encode(['success'=>false,'error'=>'Sunucu errorsı']);fetch('/api/profile')fetch('/api/profile', { credentials: 'same-origin', headers: { Accept: 'application/json' } })Chrome DevTools Console, Sources, and Network panels should be examined together with real file, line, and server response.
Node version, package.json module type, build output, and the actual file run should comply with the same module system.
PHP warnings, theme HTML, redirects, and double script loading JavaScript errors may appear.
It occurs when the JavaScript parser, JSON parser, or module loader cannot find the expected grammar.
The line is usually where the parser detects the error. Missing quotes, parentheses, or commas may be in the previous line.
Use source map and DevTools pretty print; correct the original source file and rebuild.
PHP warning, HTML error page or unpadded data pressed may break JavaScript/JSON syntax.
Most parsers find most errors; however, incorrect server response, double script loading, and runtime module configuration should also be checked.
Deploy, minify, cache, package update, Node version, PHP output or half-loaded file behavior may have changed.
Provides diagnostic and safe repair steps; changes should be tested in the staging environment and reverted using Git.
We examine Console, Fetch/AJAX, PHP JSON responses, ES Modules, TypeScript build and WISECP script loading problems without disrupting the production structure.