JavaScript Validator

Check JavaScript syntax without executing the code.

Check whether JavaScript code is syntactically valid, with the line and column of the first problem. It parses the code and never executes it, so you can safely check snippets from any source, as scripts or ES modules.

What is JavaScript syntax validation?

Syntax validation parses source text against the language grammar and reports where it breaks the rules, such as a missing bracket, an unexpected token or a duplicate let declaration. It does not run the code, so it cannot detect runtime errors like calling an undefined function, nor logic bugs, nor style problems. This tool uses the acorn parser with the latest ECMAScript version. It first tries the code as a classic script and, if that fails, as an ES module, so import and export statements are accepted. Top-level return and await are tolerated, and a leading hashbang line is allowed. Because nothing is executed, checking is safe for untrusted code.

How to use JavaScript Validator

  1. Provide code Type or paste into the JavaScript editor, or load a file with the load button.
  2. Read the verdict Results appear automatically shortly after you stop typing.
  3. Locate the error A failing result lists Line and col with the message, and the editor marks the line.
  4. Clear Use the clear button to start over.

Frequently asked questions

Is my code executed?

No. It is only parsed by acorn. Nothing in it is evaluated or run.

Does it support modern syntax?

Yes. The parser targets the latest ECMAScript version, including async functions, optional chaining and classes.

Why does it say ES module?

The code failed as a script but parsed as a module, usually because it contains import or export.

Can it check TypeScript or JSX?

No. Those extensions are not standard JavaScript and are reported as syntax errors.

Does valid mean safe?

No. Syntax validity says nothing about what the code does when run.