Home › Developer Tools › JavaScript Syntax Checker

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:

Loading the Acorn parser…

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.

Advertisement
Advertisement

How to use the JavaScript Syntax Checker

  1. Paste your JavaScript into the editor, open a .js / .mjs / .cjs file, or load a sample.
  2. 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.
  3. Press Check Syntax (or Ctrl + Enter). With Check as I type on, the result updates while you edit.
  4. Read the result: a green message with code statistics, or the first syntax error with its line, column and a hint.
  5. 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:

VersionSyntax 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
ES2016Exponent operator **
ES2017async/await, trailing commas in function parameters
ES2018Object rest/spread {...obj}, for await…of, regex named groups and lookbehind
ES2019Optional catch binding catch {}
ES2020Optional chaining ?., nullish coalescing ??, BigInt literals 10n, dynamic import()
ES2021Logical assignment ??= ||= &&=, numeric separators 1_000
ES2022Class fields, private #fields and methods, static blocks, top-level await in modules
ES2023Hashbang #! comments
ES2024Regex v flag (set notation)
ES2025Import attributes with { type: "json" }, regex modifiers, duplicate named capture groups

Common JavaScript syntax errors and fixes

MessageUsual cause
Unexpected tokenA missing ), ], } or comma just before the reported position, or an extra one at it.
Unterminated string constantA 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 functionThe surrounding function is not async.
Identifier 'x' has already been declaredThe same let/const/class name declared twice in one scope.
Invalid regular expression flagA 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.

Related tools

JavaScript BeautifierFormat and beautify messy or minified JavaScript, or minify it.TypeScript FormatterFormat TypeScript and TSX code with Prettier: width, tabs, semicolons and quotes options.JavaScript MinifierMinify JavaScript with Terser: compress, mangle and see how many bytes you save.JSON ValidatorCheck JSON with the exact line and column of each error, fix tips and one-click auto-fix.Is JavaScript Enabled TestCheck instantly if JavaScript is enabled, see your JS engine and get how-to-enable steps.JSON FormatterBeautify, minify and validate JSON, with a collapsible tree view.SQL Formatter & BeautifierFormat, beautify or minify SQL queries for MySQL, PostgreSQL and more.HTML FormatterBeautify and indent HTML code with a live preview.CSS FormatterBeautify CSS with indent controls and optional property sorting.XML FormatterBeautify, validate and minify XML with a collapsible tree view.ZIP File CreatorCompress files and folders into a ZIP.YAML Validator & FormatterValidate, format and minify YAML, and convert YAML to JSON or back.HTML MinifierMinify HTML: strip comments and whitespace safely and see how many bytes you save.CSS MinifierMinify CSS with csso or a built-in engine and see the size saved instantly.JSON MinifierMinify and validate JSON, sort keys and see exactly how many bytes you save.Code Diff CheckerCompare two code files side by side or unified, with syntax colors and changes highlighted.IPv6 Expander & CompressorExpand IPv6 addresses to full form or compress them per RFC 5952, one or many at once.GraphQL FormatterPretty-print and indent GraphQL queries, mutations and schemas, or minify them, instantly.CSS ValidatorValidate CSS: syntax errors, unknown properties and invalid values by line, plus auto-fix.Gzip Compress / DecompressGzip or deflate text and files, get Base64 output, and decompress Base64 or .gz files.IBAN ValidatorCheck an IBAN's mod-97 checksum, country and length, and see its bank code and account parts.JSON Schema ValidatorValidate JSON against a JSON Schema (draft-07, 2019-09, 2020-12) with clickable error paths.Markdown FormatterBeautify Markdown with Prettier: list markers, prose wrap, aligned tables and live preview.PHP FormatterBeautify PHP code with Prettier PHP: PSR-12 style, indent and brace options, syntax errors.XML MinifierMinify and validate XML: strip whitespace and comments, keep CDATA, see the size savings.C# FormatterBeautify C# code online: Allman or K&R braces, indent size and line width, clang-format option.HTML ValidatorCheck HTML for errors and warnings with line numbers, locally or with the W3C Nu checker.Java FormatterBeautify Java code online: indent size, brace style and line width, with clang-format option.JavaScript ObfuscatorObfuscate JavaScript with string encoding, renaming and control-flow flattening presets.Phone Number FormatterFormat and validate lists of phone numbers to E.164, international or national style.Python FormatterFormat Python code in Black/Ruff style: line length, quote style, indent, copy or download.Responsive Design CheckerPreview any website at phone, tablet, laptop and desktop sizes side by side, with rotate and zoom.Browser Compatibility CheckerSearch CSS, JavaScript and HTML features and see which browser versions support them.Core Web Vitals CheckerCheck real-user LCP, INP and CLS for any URL or site and see if it passes Core Web Vitals.Heading Structure CheckerPaste HTML to see its H1-H6 outline and catch missing H1s, multiple H1s and skipped levels.Website Hosting CheckerFind out who hosts a website: hosting provider, IP addresses, ASN, network owner and location.Routing Number ValidatorCheck a US ABA routing number's checksum and format and see its Federal Reserve district.Spam Word CheckerScan an email subject and body for spam trigger words, excess caps, exclamation marks and risky links.Strftime Format BuilderBuild Python and C strftime format strings by clicking tokens, with a live preview and reference.Check Digit CalculatorCalculate or validate check digits for UPC, EAN, GTIN, SSCC, ISBN, ISSN and mod 11 codes.Luhn Algorithm CheckerValidate numbers with the Luhn mod 10 check or calculate the missing check digit, step by step.XSD ValidatorValidate XML against an XSD schema in your browser and see each error with its line number.
See all 41 Code Formatters & Validators →