invalid token JavaScript Origin: On your device OSI layer 7 · Application Last updated 10 Oct 2026

SyntaxError: Invalid or unexpected token

The code contains a character the parser can’t handle — smart quotes, stray characters or an unterminated string.

Exact message you may see Invalid or unexpected tokenillegal character
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

  1. Retype the quotes
  2. Use template literals for multi-line strings
  3. Reveal invisible characters in your editor

Detailed fix by platform

JavaScript

  1. Search for [“”‘’] and replace with straight quotes

How to diagnose

  1. Character — What is at the column reported?
  2. Recent change — Did it start after a deploy, upgrade, or configuration change? Compare with the last working version.

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

already declared — SyntaxError: Identifier 'x' has already been declared (JavaScript)already declaredawait outside async — SyntaxError: await is only valid in async functions and the top level bodies of modules (JavaScript)await outside asyncElement is missing end tag — Vue: [plugin:vite:vue] Element is missing end tag. / Invalid end tag. (Vue)Element is missing en…GraphQL Syntax Error — GraphQL: Syntax Error: Expected Name, found <EOF> / Unexpected } (API)GraphQL Syntax Errorinvalid regex — SyntaxError: Invalid regular expression: /x/: Unterminated group (JavaScript)invalid regexmissing ) — SyntaxError: missing ) after argument list (JavaScript)missing )SyntaxError — SyntaxError: invalid syntax (Python)SyntaxErrorTS1005: ';' expected / ',' expected (syntax error) — TypeScript: error TS1005: ';' expected. (TypeScript)TS1005: ';' expected …invalid t…

Explore the map of this error Full error map →

🧠 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.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.