Odds & Todds logo

Odds & Todds

Subscribe
Archives
October 16, 2025

How to fix `Unexpected token '<'`

SyntaxError: Unexpected token '<' is one of the most common JSON parsing errors on the web. It happens when JavaScript tries to parse HTML as JSON - that < character is usually the start of an HTML tag like <!DOCTYPE html> or <html>.

This error appears in your console when JSON.parse() encounters HTML instead of valid JSON data. It’s particularly frustrating because it often masks the real problem: your server returned an error page instead of the API response you expected.

Read the full story »

Don't miss what's next. Subscribe to Odds & Todds:
https://www.toddhga…
Powered by Buttondown, the easiest way to start and grow your newsletter.