CSS and HTML minifier
Remove comments and extra whitespace from CSS or HTML and see the saving.
Runs in your browser. Your input is not uploaded.
What it does
Minifying removes characters that browsers do not need: comments, indentation and extra spaces. It reduces file size before compression; gzip or Brotli then shrink the rest.
The CSS minifier keeps strings, url() values and /*! licence */ comments intact, and keeps the spaces that calc() requires around + and -.
How to use it
- Choose CSS or HTML.
- Paste the code.
- Copy the result and check the bytes saved.
Things to watch for
- This does not rename variables, merge rules or minify JavaScript. Use your build tool for that.
- Collapsing whitespace in HTML can remove a space between inline elements that you meant to keep. Spaces are reduced to one, not removed, to avoid most of these cases.
Questions
- Is minifying worth it if the server uses gzip?
- Usually a little. Compression removes most repetition, but comments and whitespace still cost bytes and parse time.
- Are licence comments kept?
- Comments starting with
/*!are kept in CSS, by convention. - Can I minify JavaScript here?
- No. Safe JavaScript minification needs a full parser such as Terser or esbuild.
- Does HTML minification remove comments?
- Yes, by default. Conditional comments and server-side includes inside comments are removed too, so untick the option if you use them.