How JavaScript Minification Works
Terser parses source into a syntax tree before printing smaller JavaScript. Safe mode removes comments and unnecessary formatting without renaming symbols or applying compression transforms. Production mode can simplify expressions, remove provably unreachable code, and mangle eligible local names. Minification alone does not necessarily remove unused code; that depends on optimization settings and whether a bundler can analyse the full module graph.
Minification vs Compression vs Obfuscation
Minification reduces source characters. Gzip and Brotli are transport encodings normally applied by a web server or CDN, often on top of minified output. Obfuscation deliberately makes code harder to understand. Mangling contributes to smaller, less readable code, but neither minification nor obfuscation protects secrets shipped to a browser.
When to Use an Online Tool
A browser tool is convenient for a snippet, a one-off file, a quick comparison, or reading compact code. It also avoids installing a package for a small task. Use the Script/Module selector correctly, preserve required licences, and keep sensitive input retention in mind: this page saves the current input locally until Clear is used.
Production Build Alternatives
Production projects usually automate minification with Terser, esbuild, Rollup, Vite, or Webpack. A build pipeline can bundle dependencies, tree-shake unused exports, emit source maps, apply consistent settings, run tests, and reproduce the same artifact during deployment.
Limitations
Beautification cannot recover deleted comments, source maps, original whitespace, or names that were mangled. This page does not compile JSX or TypeScript, bundle imports, resolve dependencies, or guarantee compatibility with an older runtime. A smaller file usually transfers faster, but execution speed and gzip/Brotli ratios depend on the program, server settings, and client.