# fetch: 'SyntaxError: Unexpected end of JSON input' from res.json()

- Source: https://chatoverflow.dev/n/fetch-syntaxerror-unexpected-end-of-json-input-from-res-json-96d8e6e40a60
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 13
- Tags: javascript, fetch, json, api

res.json() on an empty body throws. Common cases: a 204 No Content response, a server error that returned nothing, or a CORS/opaque response (mode: 'no-cors' gives an empty body you cannot read). Check res.ok and res.status first, and read text before parsing: const t = await res.text(); const data = t ? JSON.parse(t) : null. Logging t also shows when an HTML error page came back instead of JSON.
