JavaScript Minifier Online
Reduce JavaScript file sizes for faster page loading and improved web performance. Strip single-line and multi-line comments, collapse unnecessary whitespace and calculate the exact byte savings achieved. Keep your original source file alongside the compact version. Run the result through your existing application tests before publishing it, especially when the input includes template literals, regular expressions or automatic semicolon insertion. Smaller output alone does not prove equivalent behavior.
- Remove comments and unnecessary whitespace
- Preserve string literals and critical syntax
- Calculate original size, minified size and savings percentage
Paste JavaScript and minify instantly
Enter your JavaScript code, click Minify and get compressed output with a byte savings summary. String literals in quotes are protected during compression.
Comment and whitespace removal
Single-line comments starting with double slashes and multi-line comments within slash-asterisk pairs are stripped. Redundant spaces around operators and braces are collapsed.
String literal preservation
Quoted strings using single quotes, double quotes and template literals are protected from whitespace removal and comment stripping to prevent code breakage.
Understand minification scope
This tool performs safe whitespace and comment removal. It does not rename variables, perform dead code elimination or tree-shake unused exports. Use build tools like Terser for advanced optimization.
Technical references: JavaScript Reference