SyntaxError: Invalid or unexpected token
The code contains a character the parser can’t handle — smart quotes, stray characters or an unterminated string.
Seen on:
JavaScript
Meaning
Copy-pasting code from documents or chat replaces ' and " with curly quotes. Unterminated strings across lines and zero-width characters also trigger it.
Common causes
- Smart/curly quotes from Word, PDFs or chat
- Unterminated string literal
- Invisible zero-width or non-breaking space characters
⚡ Quick fix
- Retype the quotes
- Use template literals for multi-line strings
- Reveal invisible characters in your editor
Detailed fix by platform
JavaScript
- Search for [“”‘’] and replace with straight quotes
How to diagnose
- Character — What is at the column reported?
- Recent change — Did it start after a deploy, upgrade, or configuration change? Compare with the last working version.
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026