Minify JavaScript code for production — remove whitespace, comments and unnecessary characters to reduce file size and improve page load speed.
Enter your figures and click Calculate to see your results.
Paste your JavaScript, choose whether to keep license comments, then click Format to get the minified output with size savings shown.
Click the Format button. Your code is processed instantly — all formatting runs in your browser with no data sent to servers.
The formatted output appears on the right. Click Copy to grab it, or Download to save as a file. Statistics like size reduction and line count are shown automatically.
Typical JavaScript minification reduces file size by 30–60%. Minification removes whitespace, comments, and shortens local variable names. Combined with gzip or Brotli compression (applied by web servers), total savings can reach 70–85%. For example, React 18 unminified is ~1.5MB; minified ~140KB; minified + gzip ~45KB. Production builds should always use minification.
Minification removes whitespace and comments to reduce file size while keeping code functional and (somewhat) readable. Obfuscation intentionally makes code hard to understand — renaming variables to single characters, removing all meaningful names, adding confusing constructs. True obfuscation is rarely needed for web code (it can always be reverse-engineered) but is used in some DRM, anti-cheat and proprietary software contexts. Minification is standard practice; obfuscation is niche.
Source maps are files (*.map) that map minified code back to the original source. When an error occurs in production, browser dev tools use the source map to show the original file name, line number and variable names — making debugging possible despite the minification. Build tools (webpack, Rollup, Vite) generate source maps automatically. Never deploy source maps to production if you want to protect your source code.
Modern JavaScript minification tools: Terser (the current standard, used by webpack and Vite), esbuild (extremely fast Go-based bundler/minifier, used by Vite), SWC (Rust-based compiler/minifier, used by Next.js), UglifyJS (older, now largely replaced by Terser), Closure Compiler (Google, most aggressive but requires specific code patterns). These tools do far more than remove whitespace — they dead-code eliminate, inline constants and perform other optimisations.
Dead code elimination removes code that is provably never executed: unreachable code after return statements, variables that are assigned but never read, functions that are never called. Tree-shaking is dead code elimination at the module level — removing entire exported functions/variables that are never imported. Together, these can dramatically reduce bundle size. Tree-shaking requires ES module syntax (import/export) and is performed by bundlers, not simple minifiers.
Code splitting divides a JavaScript bundle into multiple chunks loaded on demand. Instead of loading a 500KB bundle for every page, you load a 50KB core bundle plus smaller page-specific chunks. Combined with minification, this dramatically reduces initial load time. React.lazy() and dynamic import() enable code splitting. Route-based splitting (loading per-page bundles) is standard in React, Vue and Angular applications.
Minification slightly improves parse time because the browser has fewer characters to tokenise. However, the primary performance benefit is network transfer — smaller files download faster. Compilation and execution speed are not meaningfully affected by minification. For runtime performance, focus on algorithmic efficiency, avoiding memory leaks, reducing DOM manipulations and using web workers for heavy computation.
Brotli is a compression algorithm developed by Google, supported by all modern browsers. It typically achieves 15–25% better compression than gzip for JavaScript files. Web servers serve Brotli to browsers that advertise support (Accept-Encoding: br). For serving minified JavaScript: Brotli achieves the best compression, gzip is the universal fallback, and zstd is emerging as a new option. CDNs (Cloudflare, CloudFront, Fastly) apply Brotli automatically.