JavaScript Minifier
Minify and compress JavaScript code instantly in your browser. Remove comments, collapse whitespace, and reduce file size. Free and private.
Drag & Drop a JS file here
Supports .js files. Or paste your JavaScript above.
Minify and compress JavaScript code instantly in your browser. Remove comments, collapse whitespace, and reduce file size. Free and private.
Supports .js files. Or paste your JavaScript above.
JavaScript minification reduces the size of source code by removing unnecessary characters and (with proper minifiers) renaming local variables to shorter names. The first category — whitespace and comment removal — is straightforward and risk-free. The second — variable renaming — requires understanding scope rules and is what production minifiers like Terser and esbuild do best.
This tool focuses on safe minification: stripping comments, collapsing whitespace, removing redundant semicolons, and shortening obvious patterns. Variable renaming is conservative — only local variables in clear scopes are touched, and externally-referenced names are left alone. The result is functionally identical to the source.
For production-grade minification, dedicated tools (Terser, esbuild, swc) understand the full ECMAScript scope model and produce significantly smaller output. This tool is for quick browser-side minification when a full build setup is not available.
JavaScript bundles are typically the largest single resource on a modern webpage. Minification routinely produces 30–60% size reduction versus the unminified source. Combined with gzip or Brotli, the reduction shrinks somewhat, but the combination still saves measurable bytes — particularly for users on slow connections.
Faster JavaScript also means faster Time to Interactive. Smaller scripts download faster, parse faster, and execute sooner. For sites where TTI affects bounce rates and SEO ranking, minification is one of the cheapest wins available.
Paste JavaScript, get a smaller version.
The minifier tokenizes JavaScript using a parser that respects ECMAScript syntax. Comments (single-line and multi-line) are removed except for license comments marked with /*! prefix. Whitespace is collapsed except where syntactically required (between identifiers, after keywords).
Conservative variable renaming shortens local variables in straightforward scopes. Globals, exports, and imported names are not renamed — that would break external references. For deep renaming, use Terser or esbuild with proper module-aware analysis.
Edge cases: automatic semicolon insertion (ASI) means the minifier must preserve newlines in some contexts to avoid changing program behavior. Template literals, regex literals, and JSX (if input includes it) are preserved exactly because their contents may not be safe to compress.