Developer Tools

JavaScript Validator

Check whether your JavaScript will even parse, without running it. The validator reads the code with a full ECMAScript parser, pinpoints a syntax error by line and column, and, when the syntax is fine, points out patterns that commonly hide bugs.

  • Runs in your browser
  • No sign-up
  • Free to use

How to use JavaScript Validator

  1. Paste your JavaScript or open a .js file.
  2. Leave the code type on automatic detection, or choose classic script or ES module.
  3. Select Validate JavaScript.
  4. Fix the reported syntax error, or review the hints; select an entry to jump to its line.

JavaScript Validator features

Standards-based parsing

Uses the Acorn parser with the latest ECMAScript syntax, including classes, async functions, optional chaining and private fields.

Exact error position

Line and column of the first syntax error, highlighted in the editor.

Scripts and modules

Understands import and export, top-level await and the stricter rules of modules.

Bug-prone patterns

Assignments in conditions, duplicate object keys, unreachable code, comparisons with NaN and duplicate case labels.

Leftovers and risks

Flags debugger statements, eval and new Function.

Never executed

The code is only parsed, never run, and it does not leave your browser.

When to use JavaScript Validator

  • Finding the missing bracket or comma that stops a script from loading.
  • Checking a snippet from a forum or an AI assistant before using it.
  • Reviewing a script for leftover debugger statements before release.
  • Verifying hand-edited minified code or configuration written as JavaScript.

JavaScript Validator FAQ

What is the difference between a syntax error and a runtime error?

A syntax error means the code is not valid JavaScript: a bracket is missing, a keyword is misplaced. The whole file is rejected and nothing in it runs. A runtime error happens while valid code executes, for example when calling a function that does not exist. This validator finds syntax errors for certain and hints at some runtime problems.

Why is only one syntax error shown?

Once the parser hits invalid syntax it cannot know how the rest was meant, so anything reported afterwards would be guesswork. Fix the first error and validate again; often a single missing brace is the only problem.

Does it support JSX or TypeScript?

No. Both are extensions that have to be compiled to JavaScript first. Type annotations and JSX tags are reported as syntax errors here because browsers would reject them too. Validate the compiled output.

What is the difference between script and module?

Modules are always in strict mode and may use import, export and top-level await. Classic scripts may not. Automatic detection tries the module rules first and falls back to script rules, so both kinds validate without a setting.

Are the hints errors?

No. The code is valid and will run. Hints mark constructs that are frequently mistakes, such as “if (x = 5)” where a comparison was meant, or that are discouraged, such as var and loose equality. Decide case by case.

Is it safe to paste untrusted code?

Yes. The code is turned into a syntax tree and inspected. It is never executed, so it cannot do anything, and it is not sent to a server.

What a parser can tell you about your code

Before a browser runs a single statement, it parses the entire file. If the parser finds something that does not fit the grammar of the language, the file is discarded as a whole, and the console shows one message that is sometimes far from the real cause. A missing closing brace in the first function may be reported at the last line of the file, because that is where the parser finally ran out of input. Seeing the error in an editor with the line highlighted, next to the code around it, makes such problems much quicker to resolve.

The same parser, when it succeeds, produces a syntax tree: a structured description of every statement and expression. Many typical bugs are visible in that tree without running anything. An object literal that defines the same key twice has certainly lost a value. A statement placed after a return will never execute. A condition that contains an assignment is nearly always a mistyped comparison. These are the patterns the hints report.

Some hints are about habits. Loose equality with == applies conversion rules that few people remember completely, and === avoids the question. The var keyword creates function-wide variables that can be read before they are assigned, while let and const behave the way most programmers expect. Neither is an error, and old code is full of both, but in new code the modern forms prevent a class of surprises.

A validator is not a test suite. It cannot know that a variable is misspelled if both spellings are valid names, or that a function returns the wrong result. It answers a narrower question reliably: is this JavaScript, and does it contain anything that is suspicious on its face.

Other useful tools