首页Home › 开发工具Developer Tools

🟨 JS 格式化/压缩JavaScript Beautifier & Minifier

在线美化(格式化)或压缩 JavaScript 代码,本地运行,不上传。美化基于 js-beautify,压缩基于 Terser。Beautify or minify JavaScript locally in your browser. Beautify uses js-beautify; minify uses Terser.

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

「JS 格式化/压缩」是什么?What is the JavaScript Beautifier & Minifier tool?

在线美化(格式化)或压缩 JavaScript 代码,本地运行,不上传。美化基于 js-beautify,压缩基于 Terser。Beautify or minify JavaScript locally in your browser. Beautify uses js-beautify; minify uses Terser.

如何使用「JS 格式化/压缩」?How do I use the JavaScript Beautifier & Minifier tool?

在「JS 格式化/压缩」中,按需设置「操作」、「缩进」等选项,然后点击「执行」、「复制」按钮即可。In the JavaScript Beautifier & Minifier: Set "Action", "Indent", then click "Run", "Copy".

压缩会改变代码行为吗?Does minifying change behavior?

正常情况下不会。Terser 除了移除空白和注释、重命名局部变量,还会做安全的代码优化,例如删除不可达代码和未使用的变量、常量折叠(2 + 3 → 5),结果在语义上与原代码等价。依赖 Function.prototype.toString 或函数名的代码请压缩后再测试。Normally no. Besides removing whitespace/comments and renaming local variables, Terser applies safe optimizations such as dead-code and unused-variable removal and constant folding (2 + 3 → 5); the result is semantically equivalent. Re-test code that relies on Function.prototype.toString or function names.

美化会检查语法错误吗?Does Beautify check syntax?

不会。美化只重新排版,不解析语法;代码有错误时会尽量照原样输出。需要检查语法时可切换到“压缩”,Terser 会报告错误位置。No. Beautify only re-formats and does not parse; broken code is output mostly as-is. Switch to Minify to have Terser report syntax errors.

代码或数据会被上传吗?Is my code or data uploaded?

不会。「JS 格式化/压缩」完全用 JavaScript 在本地运行,适合处理含有密钥、内部接口等敏感内容的数据。No. The JavaScript Beautifier & Minifier runs entirely in local JavaScript, so it is safe for data containing keys or internal endpoints.

「JS 格式化/压缩」免费吗?需要注册吗?Is the JavaScript Beautifier & Minifier free? Do I need an account?

「JS 格式化/压缩」完全免费,无需注册或安装,打开网页即可使用,手机和电脑都能用;输入的内容只在你的浏览器本地处理。The JavaScript Beautifier & Minifier 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

🛡️ JS 混淆加密JavaScript Obfuscator📦 JS eval 解包JavaScript Unpacker📊 Excel 转 JSONExcel to JSON📈 JSON 转 ExcelJSON to Excel🧾 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

← 全部工具All tools