HTML / CSS / JS minifier. Safe transforms only.
Your code never leaves your browser. Nothing is uploaded.
How to use the HTML / CSS / JS Minifier
This minifier makes HTML, CSS and JavaScript smaller by removing comments and extra whitespace, and in CSS by shortening hex colors. It only makes conservative changes and never renames variables or rewrites logic. Use it for one-off files, snippets for a CMS or an email, or to see how much a file could shrink.
Step by step
-
Add your code
Paste into the Input box, or use Load file to drop or pick a .html, .css or .js file of up to 10 MB. Load sample fills the box with an example in the current language.
-
Check the language
The HTML, CSS and JavaScript buttons set the language, and HTML is selected when the page opens. The tool guesses the language when you paste, and a loaded file's extension wins. If the guess is wrong, press the right button.
-
Choose the options
Each language has its own checkboxes. HTML: Strip comments, Collapse inter-tag whitespace and Trim attribute quotes (off by default). CSS: Strip comments, Shorten hex colors and Remove last semicolons. JavaScript: Strip comments, Keep /*! license comments, Remove blank lines and Trim trailing spaces.
-
Minify
The Minified output updates a moment after you stop typing. Press Minify to run it on demand and see a note with the bytes saved.
-
Copy or download
Press Copy to put the result on your clipboard, or Download to save it as minified.html, minified.css or minified.js. Clear empties both boxes.
Reading the result
- The line under the boxes shows the size before, the size after and the % saved, with a bar that fills to match. Sizes are bytes as the file would be saved, so a character such as é counts as 2.
- HTML keeps the contents of pre, textarea, script and style blocks exactly as they were, and keeps conditional comments such as [if IE].
- CSS always keeps comments that start with /*!, the usual way to mark a license. Hex colors are only shortened when no detail is lost, so #aabbcc becomes #abc.
- JavaScript output keeps your line breaks and indentation. Only comments, blank lines and trailing spaces are removed, so savings are smaller than a build tool would give.
Tips and common mistakes
- Keep your original file. Minified code is hard to read, so always edit the source and minify again.
- Inline CSS and JavaScript inside an HTML file are not minified, because style and script blocks are left untouched. Minify large blocks separately on the CSS or JavaScript setting.
- Trim attribute quotes only removes quotes around simple values like class=card. It is valid HTML5, but some older tools expect quotes, which is why it starts off.
- For full JavaScript minification with renaming and dead code removal, use a build tool such as esbuild or terser.
- Test the minified file on a real page before you replace the original.
Privacy and limits
All minification runs in your browser with code built into the page. Your code is not uploaded and nothing is saved. Files are read on your device, with a limit of 10 MB per file.
Everything a minifier should do.
[if IE] comments and pre/textarea/script blocks stay intact./*! licenses), strip last semicolons and shorten six-digit hex colors to three where it's lossless..html, .css or .js file (up to 10 MB), the language is detected automatically.Frequently asked questions.
Is the minifier free and private?
Will minifying my JavaScript break it?
Does it strip license comments and conditional HTML?
/*! license comments are retained, and HTML conditional comments like <!--[if IE]> are left in place. Contents of pre, textarea, script and style blocks are never touched.How does auto-detect know the language?
@media/@import rule or selector-with-declarations block reads as CSS, and anything else falls back to JavaScript. When you load a file, the file extension wins. If it ever guesses wrong, just switch the language toggle.Does it work offline?
Published · Last updated .