JavaScript Validator
Check your JS syntax for errors and warnings
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
- 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.
- Under Quick Lint Rules, tick any extra flags you want: Flag console.log() usage, Flag eval() usage or Flag alert() usage.
- Click Validate Syntax.
- 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