首页Home › 开发工具Developer Tools

🟨 JavaScript 校验器(JS 语法检查)JavaScript Validator

在线检查 JavaScript 语法:按最新 ECMAScript 标准解析,准确指出错误的行号、列号并标出出错位置,中文说明常见错误(缺括号、字符串未闭合、重复声明、await 用错位置等),支持普通脚本和 ES 模块,可提醒重复的对象键、条件里的赋值、debugger 和 eval,代码不上传。Check JavaScript syntax online against the latest ECMAScript standard. It pinpoints the line and column of an error with a caret under the code and explains common mistakes (missing brackets, unclosed strings, redeclared variables, misplaced await…). Classic scripts and ES modules are supported, and it can flag duplicate object keys, assignments in conditions, debugger and eval. Your code stays in the browser.

使用说明与常见问题How-to & FAQ

「JavaScript 校验器(JS 语法检查)」是什么?What is the JavaScript Validator tool?

在线检查 JavaScript 语法:按最新 ECMAScript 标准解析,准确指出错误的行号、列号并标出出错位置,中文说明常见错误(缺括号、字符串未闭合、重复声明、await 用错位置等),支持普通脚本和 ES 模块,可提醒重复的对象键、条件里的赋值、debugger 和 eval,代码不上传。Check JavaScript syntax online against the latest ECMAScript standard. It pinpoints the line and column of an error with a caret under the code and explains common mistakes (missing brackets, unclosed strings, redeclared variables, misplaced await…). Classic scripts and ES modules are supported, and it can flag duplicate object keys, assignments in conditions, debugger and eval. Your code stays in the browser.

如何使用「JavaScript 校验器(JS 语法检查)」?How do I use the JavaScript Validator tool?

在「JavaScript 校验器(JS 语法检查)」中,把内容粘贴或输入到上方输入框,按需设置「代码类型」,结果会实时显示在下方,点击「复制结果」即可复制。In the JavaScript Validator: Paste or type into the input box, adjust "Code type"; the result appears below instantly — click "Copy result" to copy it.

用什么标准检查?Which standard is it checked against?

使用 acorn 8.19(MIT 许可)按最新的 ECMAScript 规范解析,支持可选链 ?.、空值合并 ??、私有字段 #x、BigInt、顶层 await(ES 模块)、正则 v 标志等新语法。它只检查语法,不运行代码,因此不会发现变量未定义、类型错误这类运行时问题。acorn 8.19 (MIT) parses the code against the latest ECMAScript specification, including optional chaining ?., nullish coalescing ??, private fields #x, BigInt, top-level await (in ES modules) and the regex v flag. It checks syntax only and never runs the code, so runtime problems such as undefined variables or type errors aren't detected.

“普通脚本”和“ES 模块”有什么区别?What's the difference between Classic script and ES module?

ES 模块(type="module" 的 script 标签或 .mjs 文件)可以使用 import / export 和顶层 await,并且始终是严格模式;普通脚本则允许 with 语句、非严格模式下的八进制数等旧写法。选“自动”时会先按普通脚本检查,如果按模块解析能走得更远(如用到了 import),就按 ES 模块报告结果。ES modules (script tags with type="module", or .mjs files) can use import / export and top-level await and are always in strict mode; classic scripts allow older forms such as with statements and legacy octal numbers outside strict mode. Auto checks the code as a classic script first and switches to ES module if that parses further (for example when import is used).

为什么只显示一个错误?Why is only one error shown?

JavaScript 解析器遇到第一个语法错误后无法可靠地判断后面的代码结构,继续报告往往是一连串误报,所以只报告第一个错误,并标出它所在的行和列。改正后结果会立即刷新,再显示下一个错误(如果有)。After the first syntax error a JavaScript parser can't reliably tell how the following code is structured, and continuing usually produces a cascade of false errors, so only the first error is reported with its line and column. Fix it and the result refreshes instantly to show the next one, if any.

能检查 TypeScript、JSX 或 JSON 吗?Can it check TypeScript, JSX or JSON?

不能。TypeScript 的类型注解和 React 的 JSX 都不是标准 JavaScript,会被报为语法错误,工具会给出相应提示;请用对应的编译器检查。JSON 请使用本站的 JSON 校验工具。No. TypeScript type annotations and React JSX aren't standard JavaScript, so they're reported as syntax errors with a hint saying so; check them with their own compilers. For JSON, use the JSON validator on this site.

数据会上传吗?Is my data uploaded?

不会,全部在浏览器本地处理。No — everything is processed locally in your browser.

「JavaScript 校验器(JS 语法检查)」免费吗?需要注册吗?Is the JavaScript Validator free? Do I need an account?

「JavaScript 校验器(JS 语法检查)」完全免费,无需注册或安装,打开网页即可使用,手机和电脑都能用;输入的内容只在你的浏览器本地处理。The JavaScript Validator is completely free with no sign-up or install and works on phones and desktops; what you enter is processed only in your browser.

相关工具Related tools

🧾 JSON 格式化校验JSON Formatter & Validator🧪 正则表达式测试Regex Tester⏰ Cron 表达式解析Cron Expression Explainer🔀 YAML JSON 互转YAML to JSON Converter📊 CSV JSON 互转CSV to JSON ConverterⓂ️ Markdown 在线预览Markdown Live Preview🗄️ SQL 格式化/压缩SQL Formatter & Minifier🧵 字符串转义/反转义String Escape / Unescape📰 XML 格式化XML Formatter & Validator🔁 XML 转 JSONXML to JSON Converter🎀 CSS 格式化/压缩CSS Beautifier & Minifier🧾 HTML 格式化/压缩HTML Beautifier & Minifier

← 全部工具All tools