How to Use the JavaScript Validator
- Paste your JavaScript into the input panel.
- Click Validate JS.
- A green badge confirms the code parses; a red badge shows the SyntaxError message.
- 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.
- Parse-only via the Function() constructor — no execution
- Detects modern ES syntax (optional chaining, classes, async/await)
- Returns the engine's own SyntaxError message
- Live char counter on the input
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.