JavaScript Minifier
Safely strip comments and indentation from JavaScript for smaller files.
Safe JavaScript minification
The JavaScript Minifier processes your code with a tokenizer that understands strings, template literals and regular expressions. It removes comments and indentation without any transformation that could change the code's meaning.
ASI-safe
Line breaks are kept where they matter, so code written without semicolons still follows the automatic semicolon insertion (ASI) rules and behaves the same after minification.
When to use it
Ideal for small scripts, analytics snippets, bookmarklets and projects without a build process. For advanced compression that shortens variable names, use a build tool like Terser or esbuild. Processing happens in your browser.
How to use JavaScript Minifier
- Paste your JavaScript code.
- The minified output is produced.
- Test the code in your environment.
- Copy the result.
Why use this tool?
A quick minification with the lowest risk of breaking code; your source never reaches a server.
FAQ
Does it shorten variable names?
No. It's a safe whitespace-and-comments minifier; use a build tool such as Terser if you need name mangling.
Can I minify TypeScript?
Compile it to JavaScript first; type annotations aren't supported.
Are licence comments kept?
Comments are removed; add licence information back at the top of the minified file.
Related tools
CSS Minifier
Shrink your CSS files by removing comments and unnecessary whitespace.
Open toolHTML Minifier
Safely remove comments and extra whitespace between tags to shrink your HTML.
Open toolJSON Minifier
Remove all unnecessary whitespace from JSON for smaller, faster-to-transfer data.
Open toolRegex Tester
Test JavaScript regular expressions with live match and capture group highlighting.
Open tool