JavaScript Minifier Online — Compress & Mangle JS Free
A free JavaScript minifier that compresses JS files by removing whitespace, comments, and optionally mangling variable names using Terser — the same engine Webpack and Vite use internally. Paste your code, click Minify, and get production-ready output instantly. Everything runs in your browser; your code is never sent to a server.
Features
Powered by Terser
Uses the same battle-tested minifier as Webpack, Vite, and esbuild for reliable, spec-compliant output.
Variable name mangling
Toggle mangle mode to shorten local variable and function names from readable identifiers to single characters.
Drop console.log
One-click option to strip all console.log, console.warn, and console.error calls — useful for production builds.
Size savings report
Shows original vs minified byte count and the percentage reduction so you can evaluate the impact immediately.
How to minify JavaScript online
Compress any JS file to its smallest form in seconds — no install, no CLI required.
- Paste your JavaScriptDrop your source code into the left panel. Any valid JS is accepted — ES5, ES6+, modules, or CommonJS.
- Choose optionsEnable Mangle names to shorten identifiers further. Enable Drop console.log to strip debug output from the build.
- Click MinifyTerser compresses the code in your browser. The minified output appears in the right panel.
- Copy the outputUse the Copy button to grab the minified code and paste it directly into your project or CDN.
Examples
Minify a simple function
function greetUser(name) {
// Say hello to the user
const message = "Hello, " + name + "!";
console.log(message);
return message;
}function greetUser(n){const e="Hello, "+n+"!";return console.log(e),e}With mangle enabled, "name" becomes "n" and "message" becomes "e". Drop console.log removes the console.log call entirely.
Frequently Asked Questions
- What is JavaScript minification?
- Minification removes all characters from source code that are unnecessary for execution — whitespace, comments, and newlines — and optionally shortens identifiers. The result is functionally identical but much smaller, which reduces bandwidth and speeds up page load.
- Is the minified code safe to use in production?
- Yes. Terser is the industry-standard JS minifier used by Webpack, Vite, Parcel, and Rollup. The output is spec-compliant and has been battle-tested across billions of production deployments.
- What does "mangle variable names" do?
- Mangling renames local variables and function parameters from long names (e.g. "userAccount") to short ones (e.g. "a"). This saves additional bytes. It is safe for non-exported code but should not be used if your code relies on function.name or arguments.callee.
- Will minification break my code?
- Standard minification (whitespace removal, comment stripping) never breaks code. Mangling can cause issues if your code uses eval() with variable names or relies on string-to-variable lookup. If you hit errors, disable Mangle and try again.
- Should I minify before or after bundling?
- Minify after bundling. Bundle first to resolve imports and tree-shake unused code, then minify the single output file. Most bundlers (Webpack, Vite, Rollup) run Terser as the last build step automatically.
- Does this tool support TypeScript or JSX?
- The minifier processes plain JavaScript. Compile TypeScript or JSX to JS first (e.g. using tsc or Babel), then paste the compiled output here for minification.