JS Minifier – Compress & Minify JavaScript Online Free
Remove comments, whitespace, and dead code from JavaScript instantly. See exact byte savings. Upload a .js file or paste code directly. Optionally strip console.log statements for cleaner production output.
How This JS Minifier Works
This JS minifier uses a token aware state machine to safely strip comments and whitespace from JavaScript without corrupting string literals, template literals, or regex patterns. It understands the difference between a division operator and a regex delimiter, and preserves the exact content of any quoted string.
Unlike simple search and replace minifiers, this tool handles edge cases like comments inside strings, escaped quotes, and nested template literal expressions. Banner comments (starting with /*!) are optionally preserved to comply with open source license requirements.
This is a whitespace and comment minifier, not a full compiler. It does not rename variables, tree shake unused code, or apply dead code elimination. For those features in production, use Terser, esbuild, or your bundler’s built in minification step.
What this tool does
How to use it
Paste or upload JS
Paste JavaScript into the left panel or click Upload to load a .js file.
Set options
Choose whether to keep banner comments and whether to strip console.log calls.
Minify
Click Minify JS. The output appears instantly with size stats.
Copy or download
Copy the minified code to clipboard or download it as a .js file.
Questions About the JS Minifier
JavaScript minification removes all characters from a script that are not needed for it to execute correctly: comments, newlines, extra spaces, and sometimes semicolons. The result runs identically to the original but transfers faster over the network. Minification is a standard production build step for any web application that ships JavaScript.
No. This is a whitespace and comment stripper, not a full compiler. It does not mangle variable names, tree shake unused code, or inline constants. For full optimization in production, use Terser (via Webpack or Vite), esbuild, or the Closure Compiler. This tool is ideal for quick one off minification, legacy scripts, or small projects without a build pipeline.
Not if your code is syntactically correct and doesn’t depend on automatic semicolon insertion in non standard ways. The minifier preserves all string and regex literals exactly. Always test minified output in your target browsers before deploying. If you have issues, the most common cause is code that was already relying on implicit newline as semicolon behavior in an edge case.
Console statements left in production code can expose internal data structures, variable names, API responses, and debugging information to anyone with browser DevTools open. They also add a small performance cost since the browser has to evaluate the arguments even if DevTools is closed. Removing them is a standard production hygiene practice. Enable the option in this tool to strip them automatically.
Whitespace and comment removal typically reduces file size by 10 to 30 percent on well commented code. Full minification with variable renaming (Terser) can reduce size by 30 to 60 percent. Combined with gzip or Brotli compression from the web server, the total reduction compared to the original file is typically 70 to 85 percent.
This tool works on plain JavaScript. TypeScript must be compiled to JavaScript first before minifying. ES module syntax (import/export) passes through correctly since this tool strips only comments and whitespace without parsing the module graph. Minify the compiled JavaScript output, not the TypeScript source.
No. All minification runs in your browser as JavaScript. Your source code never leaves your machine. This makes it safe to use with proprietary application code, internal APIs, or any code you would not want to transmit to a third party server.
Minification removes whitespace and comments to reduce file size while keeping the code readable to a developer who formats it. Obfuscation intentionally makes code hard to understand by renaming variables to meaningless names (a, b, x1), encoding strings, and inserting confusing control flow. Minification is for performance; obfuscation is for intellectual property protection. This tool does minification only.