Home › Code and dev › JavaScript Formatter
🔧

JavaScript Formatter

Beautify or minify JavaScript with indentation options and comment control

格式化选项
输入 JS 代码
美化结果

About this tool

The JavaScript formatter beautifies or minifies JS code:

  • Beautify: expand minified code into readable indented output with 2 spaces, 4 spaces or a tab
  • Minify: remove whitespace and newlines to cut file size
  • Comments: keep or drop them
  • Size report: original characters, result characters and the reduction
  • Live: formatting updates as you type

When to use it

  • Read a minified third-party library
  • Shrink a JS file so the page loads faster
  • Normalize code style
  • Debug JavaScript

Everything runs locally in the browser; code is never uploaded.

Minify notes

  • Savings: removing whitespace and comments usually cuts 30 to 50 percent
  • Readability: minified code is hard to read, so keep the original for debugging
  • Semicolons: some statements need a semicolon added between them to stay valid
  • Deployment: develop with the readable version and ship the minified one