Worked example
This CSS rule with a comment and loose spacing, .card { padding : 16px ; /* soft corners */ border-radius: 8px; } , becomes .card{padding:16px;border-radius:8px}: the comment, line breaks, spaces around the colon and the last semicolon are gone. The HTML list <ul> <li> One </li> <li> Two </li> </ul> becomes <ul><li> One </li><li> Two </li></ul>, keeping a single space inside each item.
What is removed and what is kept
| Removed | Kept |
|---|---|
| CSS comments | Licence comments starting /*! |
| Spaces around { } ; , > and after a property’s colon | Spaces in selectors like “nav a”, in values and in calc() |
| The last ; before the closing brace | Text inside quotes and url() |
| HTML comments | Old IE conditional comments |
| Whitespace between block tags | One space between words and inline tags |
| Runs of spaces and line breaks in text | Everything inside <pre>, <textarea> and <script> |
Minify, then compress
Minifying and server compression work together: minify first, then let the web server send the files with gzip or Brotli. Keep the original, readable files in your project and only publish the minified copies, since minified code is hard to edit. Most site builders and frameworks can do both automatically during a build; this tool is handy for one-off files, email templates and snippets pasted into a CMS.
When not to minify
Skip minifying during development, when readable code makes debugging easier, and for HTML that people will edit by hand later, such as a template in a content system. Email HTML is a special case: some email programs treat line breaks inside long lines differently, so test a minified email in the main clients before sending it to a list. If a page breaks after minifying, compare the before and after in the two boxes; with these safe rules the cause is usually invalid markup in the original, such as an unclosed tag.
Related tools
- URL encode and decode
- Colour converter
- XML formatter and validator
- SQL formatter
- CSS gradient generator
- Box shadow generator
- Meta tag analyzer
- Colour palette generator
- Contrast checker
- JSON to CSV
Sources
Checked on November 26, 2026:
- W3C: CSS Syntax Module Level 3
- WHATWG HTML Standard: the HTML syntax
- web.dev: Minify and compress network payloads
Frequently asked questions
What does minifying do?
Is this minifier safe?
,