Embed this tool on your site
About this tool
CSS Minifier strips comments, collapses whitespace and removes the last semicolon before each closing brace. Paste your CSS and the minified version appears as you type, with input and output byte counts so you can see the saving. Typical hand-formatted stylesheets shrink 20–40%; comment-heavy sheets can shrink by more than half. Smaller CSS means faster HTTP transfers and less to parse. Quoted strings are protected, spaces inside calc() and similar functions are kept, and custom properties, media queries and @keyframes pass through. The minifier uses pattern-based rules rather than a full CSS parser, so it removes spaces around every colon, comma and > — a selector such as .nav :focus becomes .nav:focus, which changes what it matches. Review the output before replacing production styles. It works entirely in your browser — no file upload, no server round-trip, and nothing is stored.
Why use it
Instant Load-Time Win: Every kilobyte removed from your CSS is a kilobyte the browser doesn't have to download before it can start rendering, and minifying needs no changes to your source files.
Exact Byte Counts Shown: Input and output byte counters show the size before and after, so you can judge whether minification is enough or whether caching or inlining would help more.
Comment Removal Built-In: License headers, TODO notes, and section dividers are useful during development but invisible to users and costly in bytes. The minifier strips all comment blocks, including multi-line /* */ styles, automatically.
No Build Tool Required: Projects without a webpack, Vite, or PostCSS pipeline still need minification. This tool handles it with a paste-and-copy workflow that works for any project size, stack, or deployment target.
Handles Modern CSS: Custom properties (--vars), calc(), clamp(), nesting, @layer and @keyframes pass through; quoted strings are protected and the spaces inside calc() are kept.
Completely Private: Your CSS runs through browser-side JavaScript only. Proprietary design tokens, internal class names, and unreleased UI code never leave your machine — no analytics on content, no server logs.
How to use
- Paste your raw CSS into the input panel on the left.
- The minified output appears instantly in the right panel — no button required.
- Check the Input bytes and Output bytes counters below the result to see the saving.
- Click 'Copy result' to copy the minified CSS to your clipboard.
- Review selectors that have a space before a colon, such as .nav :focus — the minifier removes that space.
- If you edit the input after copying, the output and size stats update automatically in real time.
When it helps
- Before deploying a static site or updating a CDN-hosted stylesheet for a production release.
- When auditing an existing production site and you suspect the CSS hasn't been minified in the current pipeline.
- After hand-writing CSS without a build tool and needing a quick minification step before shipping.
- When comparing the output of different CSS preprocessors or frameworks to understand their whitespace overhead.
- After copying CSS from design tools like Figma exports that include verbose comment blocks and redundant formatting.
- When testing whether minification alone is enough to pass a Lighthouse performance threshold without restructuring the stylesheet.
Examples
01Basic rule with comments
Input/* Primary button styles */
.btn-primary {
background-color: #f5c842;
color: #0d0d0d;
padding: 10px 20px;
border-radius: 8px;
/* Remove default border */
border: none;
cursor: pointer;
}
Expected result.btn-primary{background-color:#f5c842;color:#0d0d0d;padding:10px 20px;border-radius:8px;border:none;cursor:pointer}
02Media query with nested rules
Input@media (max-width: 768px) {
.sidebar {
display: none;
}
.main-content {
width: 100%;
padding: 16px;
}
}
Expected result@media (max-width:768px){.sidebar{display:none}.main-content{width:100%;padding:16px}}
Input · Scroll for more:root {
--bg: #0d0d0d;
--accent: #f5c842;
--radius: 8px;
}
.card {
background: var(--bg);
border-radius: var(--radius);
border: 1px solid var(--accent);
}
Expected result:root{--bg:#0d0d0d;--accent:#f5c842;--radius:8px}.card{background:var(--bg);border-radius:var(--radius);border:1px solid var(--accent)}
Tips
- Paste your CSS before and after a redesign to compare savings — sometimes a refactor that looks cleaner actually adds bytes.
- Keep the unminified source in version control and only commit the .min.css output to your deployment branch or CDN upload.
- If your minified output is still large, check for duplicate rules or unused selectors — minification compresses but doesn't deduplicate.
- Combine minification with gzip or Brotli compression on your server; the two techniques compound and can reduce transfer size by 80–90%.
- For critical CSS inlined in <head>, even small reductions matter — every byte here delays first paint, so minify aggressively.
Frequently Asked Questions
Will minification break my CSS selectors or media queries?⌄
Usually not. The minifier removes comments, whitespace and the last semicolon in each block, and otherwise keeps values, at-rules and selectors. One exception: spaces around colons are removed everywhere, so a descendant pseudo-class selector like .nav :focus becomes .nav:focus. Check selectors of that form before deploying.
How much size reduction should I expect?⌄
Hand-written CSS with generous formatting typically shrinks 20–35%. Comment-heavy files or code exported from design tools can shrink 40–60%. Already-compact CSS may only shrink 5–10%.
Does the tool handle vendor-prefixed properties like -webkit- and -moz-?⌄
Yes. Vendor prefixes are treated as standard property names and are preserved in full. Only the surrounding whitespace and comments are removed, leaving every prefixed rule intact.
Can I minify a CSS file instead of pasting text?⌄
The current version accepts pasted text. For a file workflow, open the CSS in any text editor, select all, paste here, then copy the output and overwrite the original file with your editor's save.
Is the output safe to use directly in a <style> tag or as an external .css file?⌄
Yes. Minified CSS is syntactically valid and can be used anywhere you would use the original. Browsers parse minified and formatted CSS identically.
What happens to @charset and @import rules at the top of the file?⌄
@charset and @import declarations are preserved in their original positions and are not reordered or removed, since moving them would change how the browser processes the stylesheet.
Does it support CSS custom properties (variables)?⌄
Fully. Custom property declarations like --brand-color: #f5c842 and var() references are preserved exactly because they are part of the property value, not structural whitespace.
Will removing comments affect source maps or debugging?⌄
This tool does not generate source maps. If you need source maps for DevTools debugging, keep the unminified version in your repository and use this tool only for the production artefact.
Glossary
- Minification
- The process of removing all characters from source code that are not required for execution or rendering — spaces, newlines, comments — to reduce file size without changing behaviour.
- Critical CSS
- The subset of CSS rules needed to render above-the-fold content. Inlined in <head> to eliminate a render-blocking stylesheet request; must be aggressively minified.
- Gzip
- A lossless compression algorithm applied by web servers to text assets before transfer. Works best on repetitive text; minified CSS compresses even further with gzip enabled.
- Custom Property
- A CSS variable declared with a -- prefix, e.g. --color-brand, that can be referenced with var(). Preserved by minifiers because the value is semantic, not formatting.
- @keyframes
- A CSS at-rule that defines animation keyframe stops. Minifiers must understand @keyframes block structure to avoid accidentally collapsing percentage values into invalid syntax.
- Whitespace Collapsing
- Reducing consecutive spaces, tabs, and newlines in source code to nothing (or a single space where required by syntax) — the primary technique behind CSS minification.
A LITTLE HELP. A LOT DONE.
Good tools.
Great flow.
Your shortcut to the everyday. Create, convert, calculate,
and get back to what you love.
✳
✳
✓ Free to use✓ No sign-up✓ 500+ possibilities