JavaScript Syntax Checker
Paste JavaScript to find syntax errors instantly, with the exact line and column, a code frame and a plain-English hint. Choose the ECMAScript version and script or module mode to check code against the environment you target.
Last updated:
Tip: press Ctrl + Enter to check; Tab indents inside the editor (press Esc first to move focus). Your code is parsed locally and never uploaded or executed.
How to use the JavaScript Syntax Checker
- Paste your JavaScript into the editor, open a .js / .mjs / .cjs file, or load a sample.
- Choose the ECMAScript version you target (Latest by default) and the source type: Module for import/export code, Script for classic scripts, or Auto-detect.
- Press Check Syntax (or Ctrl + Enter). With Check as I type on, the result updates while you edit.
- Read the result: a green message with code statistics, or the first syntax error with its line, column and a hint.
- Jump to the error with Show in code, fix it, and repeat until the code is valid. Copy the report if you need to share it.
Which syntax needs which ECMAScript version
Set the ECMAScript version to the oldest environment you support; the checker then rejects syntax that environment cannot parse. Common milestones:
| Version | Syntax it added (examples) |
|---|---|
| ES5 (2009) | Strict mode directive, getters and setters in object literals, trailing commas in object literals |
| ES2015 (ES6) | let/const, arrow functions, classes, template literals, destructuring, default and rest parameters, spread, for…of, generators, import/export |
| ES2016 | Exponent operator ** |
| ES2017 | async/await, trailing commas in function parameters |
| ES2018 | Object rest/spread {...obj}, for await…of, regex named groups and lookbehind |
| ES2019 | Optional catch binding catch {} |
| ES2020 | Optional chaining ?., nullish coalescing ??, BigInt literals 10n, dynamic import() |
| ES2021 | Logical assignment ??= ||= &&=, numeric separators 1_000 |
| ES2022 | Class fields, private #fields and methods, static blocks, top-level await in modules |
| ES2023 | Hashbang #! comments |
| ES2024 | Regex v flag (set notation) |
| ES2025 | Import attributes with { type: "json" }, regex modifiers, duplicate named capture groups |
Common JavaScript syntax errors and fixes
| Message | Usual cause |
|---|---|
| Unexpected token | A missing ), ], } or comma just before the reported position, or an extra one at it. |
| Unterminated string constant | A quote is not closed, or a normal string spans several lines. |
| Unexpected character '“' | Curly quotes pasted from a word processor or chat app. |
| 'import' and 'export' may appear only with 'sourceType: module' | Module code checked as a classic script. |
| Cannot use keyword 'await' outside an async function | The surrounding function is not async. |
| Identifier 'x' has already been declared | The same let/const/class name declared twice in one scope. |
| Invalid regular expression flag | A typo in regex flags, or a flag your selected ES version does not support. |
Once the code is valid, tidy it with the JavaScript Beautifier or shrink it with the JavaScript Minifier.
Frequently asked questions
Is my code run or uploaded?
Neither. The code is only parsed by the Acorn JavaScript parser inside your browser. It is never executed, so it cannot have side effects, and nothing is sent to a server.
Why does it show only one error at a time?
A JavaScript parser cannot reliably continue after a syntax error, because everything that follows may be interpreted differently. Like browsers and Node.js, the checker reports the first error; fix it and the next one, if any, appears.
What is the difference between Module and Script?
Modules allow import and export, are always in strict mode and allow top-level await (ES2022+). Classic scripts are what a plain <script> tag or older Node.js files use: import/export are syntax errors, and some sloppy-mode syntax such as with statements or octal literals is allowed. Auto-detect tries module first and falls back to script.
Does it find runtime errors or undefined variables?
No. It checks grammar only. Calling a function that does not exist, using an undefined variable or a type mismatch are runtime or lint problems, not syntax errors. Use a linter such as ESLint for those.
Can it check JSX or TypeScript?
No, because neither is standard JavaScript. JSX and TypeScript type annotations produce syntax errors, and the tool tells you when the code looks like one of them. Format TypeScript and TSX with the TypeScript Formatter instead.
What does Minimum ES version mean?
It is the oldest ECMAScript edition whose grammar accepts your code. For example optional chaining (?.) requires ES2020 and private class fields (#x) require ES2022. It reflects syntax only; built-in methods such as Array.prototype.at are not counted.
Which line and column numbering is used?
Lines and columns both start at 1, as in most editors. The column counts characters, so a tab counts as one column.
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.