SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON in JavaScript: 10 Causes and Fixes for JSON.parse and fetch (Tested Examples)
SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON means your code tried to parse an HTML page as JSON, usually from fetch(). Here are 10 real causes of this and related JSON.parse errors, with tested output from Node 24 and Chrome, and a safe fix for each.