← All tools
// CODE

JS Validator online

Check JavaScript syntax for errors — reports line and column numbers instantly.

JavaScript Validator logo
by
CHUNKY
MUNSTER
JAVASCRIPT INPUT0 CHARS

About JS Validator

This tool uses the browser's native JavaScript engine (via Function() constructor) to attempt parsing your code and catch syntax errors. It reports the error message along with the line number when available. Note: it detects syntax errors only — not runtime or logic errors. All validation happens in your browser.

Common JS syntax errors

How to Use the JavaScript Validator

  1. Paste your JavaScript into the input panel.
  2. Click Validate JS.
  3. A green badge confirms the code parses; a red badge shows the SyntaxError message.
  4. Fix the reported issue and re-validate.

JavaScript Validator feeds your source into new Function(code), which forces the browser's parser to validate the whole snippet without running it. If parsing succeeds you get a green badge; if it fails the SyntaxError thrown by the engine is shown verbatim, including the position information that Chrome, Firefox and Safari each format differently.

How the JavaScript Validator Works

Because it is the same parser that runs your code at runtime, the validator catches every syntactic error your runtime would: missing brackets, unclosed strings, reserved-keyword misuse, malformed arrow functions, broken template literals. It does NOT catch logic bugs, undefined-variable references, or top-level ESM import statements (Function() always parses script mode). For those use ESLint, TypeScript or Biome.

Frequently Asked Questions

Does this run my code?

No. The Function(code) constructor only parses the source — it returns a function object without invoking it. Side effects, network calls and timers do not fire. The validator is therefore safe to use on untrusted snippets.

Why does my top-level return give a syntax error?

Function() wraps your code in a function body, so a bare return is allowed. But a return on one line followed by a value on the next line is misread because of automatic-semicolon-insertion. Wrap multi-line returns in parentheses.

Will it catch ESM import/export errors?

Only partially. Function() parses script-mode JavaScript, not module mode, so import/export at the top level is flagged as a SyntaxError even though it is valid in a real ES module.

Can it find logic bugs or runtime errors?

No — only syntax errors. Things like undefined variables, type errors, infinite loops or wrong function arguments only surface at runtime. For deeper static analysis use ESLint, TypeScript or Biome.

Explore the full suite of Code tools and 290+ other free utilities at Chunky Munster.