JavaScript Validator
Check JavaScript syntax and pinpoint errors.
JavaScript Validator – Check JS Syntax Online
The JavaScript validator (JS validator) checks whether your code is syntactically valid JavaScript. If it is not, you get the exact line and column of the error and a code frame with a caret pointing to the problem — much faster than reading a minified browser error.
How it works
Your code is parsed with Acorn, the small, standards-compliant JavaScript parser used inside webpack, Rollup, and many other tools. Acorn follows the latest ECMAScript specification, so modern syntax such as optional chaining, class fields, private methods, top-level await, and import/export is recognized.
Options
- Code type – ES module allows
import/exportand top-levelawaitand applies strict-mode rules. Classic script is for code loaded with a regular<script>tag, where those statements are not allowed. - Allow JSX – accept React-style JSX elements.
The report
For valid code, the report confirms there are no syntax errors and lists simple statistics: lines, top-level statements, functions, classes, imports, and exports. For invalid code, it shows the error message, the position, and a code frame:
> 3 | if (name.length > 10 {| ^
Common syntax errors
- A missing closing parenthesis, bracket, or brace.
- A trailing operator (
a +) or a missing comma between object properties. - Using
awaitoutside an async function in a classic script. - Reserved words such as
classorenumused as variable names. - Strict-mode violations in modules, such as duplicate parameter names or
withstatements.
What it does not check
This is a syntax check. It does not run your code, find undefined variables, or enforce style rules — use ESLint for linting and TypeScript for type checking.
Related tools
Format valid code with the JavaScript Beautifier, minify it with the JS Minifier, and check your stylesheets with the CSS Validator.
Frequently Asked Questions
Does the validator run my code?
No. It only parses the code to check syntax. Nothing is executed, and the code never leaves your browser.
Can it validate TypeScript?
No. TypeScript type annotations are not JavaScript syntax. Paste the code into the TypeScript Beautifier, which reports TypeScript syntax errors.
Why does valid browser code fail in module mode?
ES modules are always strict mode. Code that uses with statements, octal literals, or duplicate parameter names is only valid as a classic script.
Does it find undefined variables?
No. That is a linting task. The validator checks whether the code can be parsed; use ESLint to find undefined variables and other bugs.