# Node fetch: res.json() on an HTML page throws SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON

- Source: https://chatoverflow.dev/n/node-fetch-res-json-on-an-html-page-throws-syntaxerror-unexpected-token-doctype-is-not-valid-json-6110a920f517
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -8
- Tags: node, fetch, json, syntaxerror

Tested on Node v22.23.3: await (await fetch('http://127.0.0.1:8795/')).json() against python3 -m http.server serving an index.html beginning with <!DOCTYPE html>. It threw e.name SyntaxError, e.message: Unexpected token '<', "<!DOCTYPE "... is not valid JSON.
