Back to Tools

JavaScript Validator

Check your JS syntax for errors and warnings

JavaScript Tool
Paste Script

Find out whether your JavaScript parses, before you run it

A missing brace or a stray comma can stop an entire script from loading. The JavaScript Validator hands your code to the browser's own JavaScript engine and reports whether it compiles. If it does not, you get the engine's error message, which is the same wording you would see in the developer console. The code is not executed while it is being checked.

Running a check

  1. Paste your script into Paste Script. The Load Sample button inserts a short function with a missing brace, so you can see a failure state.
  2. Under Quick Lint Rules, tick any extra flags you want: Flag console.log() usage, Flag eval() usage or Flag alert() usage.
  3. Click Validate Syntax.
  4. Read the result card. A green Syntax Valid card means no syntax errors were found, and any lint warnings appear beneath it in amber. A red Syntax Error Detected card shows the engine's message.

What it checks and what it does not

The syntax check uses the JavaScript function constructor, which parses the code as the body of a function. That covers missing brackets, unterminated strings, invalid tokens and misplaced keywords. It does not find runtime problems such as calling an undefined function, using the wrong variable name or a failing network request. The three lint options are simple text searches for the strings console.log, eval( and alert(, so they will also match those words inside comments or strings.

When it comes in handy

  • Checking a snippet from a client or CMS before pasting it into a page template.
  • Locating the reason a script tag silently fails, without opening devtools.
  • Spotting leftover debug calls before publishing a snippet.
  • Verifying generated code, such as output from a template or another converter.

Things to keep in mind

Because the code is parsed as a function body, top-level ES module statements such as import and export will be reported as errors even though they are valid in a module file. Top-level await behaves the same way. The error message does not always give a line number, so if you get a vague result, split the script into smaller parts and validate each. Validation happens in your browser.

Related Tools


Frequently Asked Questions

Does the validator run my code?
No. It compiles the code as a function body to check the syntax but never calls that function, so nothing in your script is executed. Runtime problems, like undefined variables, will not be detected.
Why does it report an error for my import statement?
The code is parsed as the body of a function, where import and export declarations are not allowed. They are valid in ES module files, so this is a limitation of the checker, not necessarily a bug in your code.
What do the lint checkboxes do?
They search the text for console.log, eval( or alert( and add an amber warning if found. The warning appears only when the syntax is valid, and the search cannot tell code from comments or strings.
Will it tell me which line has the error?
It shows whatever message the browser's JavaScript engine gives, which sometimes includes position details and sometimes does not. For long scripts, validating smaller sections one at a time helps you narrow the location of the problem.
Can it validate JSON or TypeScript?
It is built for JavaScript. A plain JSON object is usually reported as an error because its braces are read as a code block, and TypeScript syntax such as type annotations will be reported as an error, so use a dedicated validator for those.
Support Chat
We typically reply within minutes

Hello! 👋 Before we start, please tell us your name.