SyntaxError: Unexpected token: How to Fix It | SheCodes

Typo in the code · Usually quick to fix

SyntaxError: Unexpected token

There’s a typo or formatting mistake in the code: a missing bracket, comma, or quote.

What the error looks like

SyntaxError: Unexpected token '<'

Why it happens

The code has a structural problem: a missing closing bracket, an extra comma, a forgotten quote mark, or mixing up single/double quotes.

How to fix it

  1. Look at the line number in the error. The problem is usually there or one line above
  2. Check for missing closing brackets: }, ), or ]
  3. Look for unclosed strings (missing quote marks)
  4. Ask your AI tool to fix the syntax error, pasting the exact error message

Ask your AI coding tool to fix it

Paste this prompt into Claude Code, Cursor, Bolt or Lovable, with your own error in place of the example.

I'm getting this error and I need help understanding and fixing it:

```
SyntaxError: Unexpected token '<'
```

Please:
1. Explain what this error means in plain English
2. Tell me the most likely cause
3. Give me the exact code changes or commands I need to fix it
4. Show me how to prevent this error in the future

Got a different error?

Paste any error into the free Error Decoder and get it explained in plain English, with a fix prompt.

Decode my error

More common errors explained