HTML, CSS and JavaScript minifier.
Paste HTML, CSS or JavaScript to remove comments and extra spaces, and see how many bytes you save. It takes the careful approach: it never renames variables or rewrites your code, so it's very unlikely to break anything. Your code stays in your browser.
- Free, no sign-up
- Runs in your browser. Nothing you enter is sent to us.
Minified
How to use the HTML, CSS & JS Minifier
- Choose HTML, CSS or JavaScript.
- Paste your code. The minified version appears straight away.
- Check the size saved, then copy or download the result.
- Test the page once you've replaced the file, and keep your original to edit.
How much difference does minifying make?
Minifying often saves 10 to 30 percent of a file's size before compression. But your server should also be compressing files with gzip or Brotli, and that often has a much bigger effect. Run the page size checker to see whether compression is on and which files are heaviest. On most sites, images are the bigger win, so try the image compressor too.
What this minifier does and doesn't do
- HTML: removes comments and extra whitespace, and minifies inline scripts and styles. It leaves pre and textarea alone, and conditional comments stay.
- CSS: removes comments and spaces that do nothing, and keeps spaces inside calc() that are needed.
- JavaScript: removes comments and needless spaces. It keeps a line break wherever removing one could change what the code means.
- It doesn't rename variables or remove unused code. For the smallest possible JavaScript, use a build tool such as Terser or esbuild.
- Comments starting with /*! are kept, since they're often licence notices.
On WordPress?
You rarely need to do this by hand, because a good caching plugin can minify files automatically. Whatever you use, keep your original files, since minified code is hard to edit. To make minified HTML readable again, use the HTML formatter.
About the HTML, CSS & JS Minifier.
Can minifying break my code?
This tool is deliberately careful, and it checks that minified JavaScript is still valid where your browser allows that. Unusual code can still behave differently, so always test the page afterwards.
Is minifying the same as compression?
No. Minifying removes unneeded characters from the file itself. Compression, such as gzip or Brotli, is applied by the server as the file is sent. Use both.
Does minifying improve SEO?
Only slightly and indirectly, through faster pages. On its own it will not move your rankings.
Why is the saving so small?
The code may already be minified, or it may have few comments and spaces to remove. That is normal.
Is my code uploaded?
No. It is all done in your browser.
You might also need these.
HTML Formatter & Beautifier
Turn messy or minified HTML into clean, indented code you can read, in your browser.
Use the toolPage Size & GZIP Compression Checker
Measure a page's download weight (HTML, CSS, JS, images), its largest files and whether compression is on.
Use the toolWebsite Speed Test
Measure server response time, redirects, compression and page weight, with a plain fix for each problem.
Use the toolWant this done for you?
Free tools show you what to fix. We fix it, measure it, and keep it working while you run the business.