About the JavaScript Validator
This validator checks whether JavaScript code is syntactically valid, the way a browser or Node.js would when loading it, but without running anything. Paste code and it is parsed with Acorn, the parser used by many build tools. If there is an error, you get the line and column, a plain message and the lines around it with a pointer. You can check code as a classic script or as a module with import and export, and test against the latest JavaScript, ES2015 or ES5 for old browsers.
Updated October 2026
How to use the JavaScript Validator
- 1Paste or type your JavaScript.
- 2Choose Script or Module.
- 3Choose the JavaScript version to check against.
- 4Read the result: a green message, or the error with its location.
- 5Fix the line and the check runs again as you type.
Reading the error
The message says what the parser expected and where it gave up. The real mistake is often just before that point, such as a missing bracket on the line above. Look at the lines shown above the pointer as well as the line it points to.
Common syntax errors
These cause most failed checks.
- Unexpected token: a missing or extra bracket, comma or quote
- Unterminated string constant: a quote that isn't closed
- Unexpected token at the very end: a { or ( that is never closed
- Identifier has already been declared: the same let or const twice
- Cannot use keyword 'await' outside an async function: switch to Module or add async
Script or module?
Code loaded with <script type="module">, ES modules in Node.js and most bundled source files are modules. They allow import, export and top-level await and are always in strict mode. Older inline scripts and many snippets are classic scripts.
Checking for old browsers
If code must run on very old browsers or embedded devices, check it in ES5 mode. Anything newer should be compiled with a tool such as Babel or esbuild before release.
Valid syntax is only the first step
Code can parse perfectly and still fail when it runs, for example by calling a function that doesn't exist or reading a property of undefined. After this check, run the code with real data, use your browser's console to catch runtime errors, and use a linter such as ESLint and tests to catch mistakes in logic. Think of this validator as the quick first gate before those.
Phone and computer
The editor box is large on a computer and stacks above the result on a phone. Checking waits a moment after you stop typing, so it stays fast. A syntax check is a good first step, then tidy and shrink the code. Use the Code Beautifier to make it readable, the HTML, CSS & JS Minifier to shrink it, and the Regex Tester when a pattern is the problem. For data files, the JSON Validator does the same job.
Features
- Line, column and a pointer to the error
- Script or module (import/export)
- Latest, ES2015 or ES5
- Checks as you type
- Code is parsed, never run
- Nothing is uploaded
Frequently asked questions
What does a JavaScript validator check?
Syntax: brackets that match, valid keywords, commas and semicolons in the right places, and features allowed in the chosen version. It doesn't check whether variables exist or whether the logic is right.
Why does import or export give an error?
They are only allowed in modules. Switch Code type to Module, or remove them if the file is a plain script.
Why does my code fail as ES5?
Features like let, const, arrow functions, template literals and classes arrived in ES2015 or later. ES5 mode shows which ones would break a very old browser.
Does it support JSX or TypeScript?
No. Those are separate languages that compile to JavaScript. The validator mentions this when it spots a < where JavaScript doesn't allow one.
Is my code executed?
No. It is only parsed into a syntax tree, so pasting unknown code is safe.
Is this the same as ESLint?
No. ESLint finds style problems and likely bugs in valid code. This tool answers the first question: will this code load at all?