About this tool
Paste JavaScript to check that it parses, and see the exact line and column of any syntax error with the code around it. With Common mistakes on, it also points out code that is valid but probably wrong. The parser is Acorn, which supports the latest ECMAScript syntax.
What it finds
- Syntax errors: missing brackets and braces, unterminated strings and template literals, misplaced keywords, invalid regular expressions,
awaitoutside async functions, and more. - Likely bugs: duplicate keys in object literals (the last one silently wins), assignments where a comparison was meant (
if (x = 1)), unreachable code afterreturnorthrow, comparisons withNaN, andtypeofcompared with a misspelled type. - Style tips: loose
==comparisons,var,debuggerstatements,evaland leftoverconsolecalls.
Script or module?
ES modules are always strict and allow import, export and top-level await; classic scripts allow old sloppy-mode syntax such as with. Detect tries module first and falls back to script. JSX and TypeScript aren’t standard JavaScript, so they’re reported as syntax errors.
This is a quick check, not a full linter. For a project, ESLint catches far more, including undefined variables.
FAQ
How do I check JavaScript for syntax errors?
Paste the code. Any syntax error is shown with its line and column and a snippet with a caret under the problem.
Does it run my code?
No. It only parses the code into a syntax tree and inspects it. Nothing is executed.
Why is my JSX or TypeScript reported as an error?
They are extensions of JavaScript that browsers can’t run directly. Compile them first, or validate the compiled output.
What is the difference between script and module?
Modules are strict mode and allow import, export and top-level await. Scripts allow legacy syntax. Detect picks whichever parses.
Is my code uploaded?
No. Parsing runs in your browser.