Code Minifier
Minify JavaScript, CSS or HTML — comments and whitespace stripped, bytes saved reported.
Minify JavaScript, CSS or HTML online: comments and whitespace stripped, byte savings reported. Auto-detect picks the language; CSS is minified aggressively, JS conservatively so string literals stay intact. Everything runs in your browser.
How to minify JavaScript, CSS, or HTML
Paste code, choose JavaScript, CSS, HTML, or Auto-detect, then select Minify. The tool removes comments and unnecessary whitespace while reporting the original size, output size, and percentage saved.
This is a conservative source transformation, not a full compiler optimization pass. Test minified output in your application before deploying it, especially when processing unusual syntax or embedded content.
Example
CSS input (83 characters):
/* header */
body {
margin: 0;
color: #333333;
}
.btn:hover {
color: red;
}
Minified (49 characters, 41% smaller): body{margin:0;color:#333333}.btn:hover{color:red}. JavaScript works the same way: function add(a, b) { return a + b; // sum } spread over four lines with a comment becomes function add(a,b){return a+b;}. Variable names are kept; it removes comments and whitespace but doesn't rename or rewrite code.
How to use the Code Minifier
- Paste your code and pick the language (or leave it on auto-detect).
- Hit Minify — the output plus bytes-saved stats appear instantly.
- Copy the minified output into your production bundle.
Frequently asked questions
How do I minify JavaScript online?
Paste the code above and hit Minify. The tool strips comments and collapses whitespace outside string literals, keeping your code safe to run.
Does the minifier rename variables?
No — it performs safe minification only (comments and whitespace). For full minification with renaming, use a build tool like esbuild or terser.
How do I minify CSS?
Paste CSS and choose CSS — comments are removed and whitespace around braces, colons and semicolons is collapsed.
Does HTML minification break <pre> blocks?
No — pre, textarea, script and style blocks are protected, so their content keeps its original formatting.
Fun facts about Code Minifier
- Minification can reduce JavaScript file sizes by 30-60% by removing whitespace, comments, and shortening variable names.
- Douglas Crockford's JSMin, one of the first JavaScript minifiers (early 2000s), only removed comments and whitespace, like this tool.
- Modern bundlers like esbuild and SWC can minify code 10-100x faster than older tools like UglifyJS because they're written in compiled languages (Go, Rust).
- Minification is different from compression (gzip/brotli) — minification reduces the source code size, while compression reduces the transfer size over the network.
- Google's Closure Compiler (2009) was one of the first tools to perform 'advanced' minification — renaming variables, removing dead code, and inlining functions.