JavaScript压缩工具
基础的JavaScript压缩:移除注释和不必要的空白。生产环境请使用真正的压缩工具(Terser、esbuild)。
如何使用本工具
- 1
Paste or type your JavaScript into the input textarea.
- 2
The minified output appears instantly in the panel below as you type — there is no button to press.
- 3
Check the size readout (original length, an arrow, and minified length) to see how much was removed.
- 4
Select the text in the output box and copy it manually into your file.
什么是JavaScript压缩工具?
JavaScript压缩可减小代码包体积并缩短解析时间。本工具执行基础的空白和注释移除。对于生产环境的代码包,请使用Terser、esbuild或SWC:它们会进行变量名混淆和死代码消除,从而产生体积大幅缩小的输出(通常可减少60%到80%)。
常见使用场景
Quickly shrinking a short, comment-heavy snippet before pasting it into a tight inline <script> tag.
Stripping comments out of a code sample to share a compact version in a chat or gist.
Estimating roughly how much comment and whitespace overhead a small file carries before setting up a real build.
Cleaning up a hand-written configuration object or constant block that has no strings containing slashes.
Demonstrating to students or teammates what basic comment and whitespace removal looks like versus a real compiler.
Minifying a tiny utility function for a bookmarklet where pulling in a full toolchain is overkill.
常见问题
它和Terser相比如何?▼
这会破坏我的代码吗?▼
相关工具
JWT解码器
即时解码JSON Web Token(JWT)。完全在你的浏览器中运行:令牌绝不会离开你的设备,可安全用于生产环境的密钥。
JSON格式化与校验工具
在线格式化、校验和压缩JSON。完全在你的浏览器中运行:你的数据永远不会离开你的设备。
XML格式化工具
格式化并美化XML文档。适用于SOAP、站点地图、RSS订阅源和配置文件。
Base64编码与解码工具
将字符串编码为Base64,或将Base64解码为文本。尊重你的隐私:全部在你的浏览器中运行。
URL编码与解码工具
将文本转换为URL安全的编码(百分号编码),或进行反向转换。适用于查询字符串、重定向和OAuth流程。
HTML实体编码与解码工具
将特殊字符转换为HTML实体(&、<等),或进行反向转换。适用于将文本安全地嵌入HTML。