Code Minifier
Minify CSS and C-style code such as JavaScript, PHP and Java - comments and unnecessary whitespace are removed, strings are kept intact.
Paste CSS or C-style code - comments, line breaks and extra spaces are removed while the contents of strings stay exactly as written.
Supports C-style languages (JavaScript, PHP, Java, C/C++/C#, CSS). Strips comments and unnecessary whitespace while trying to preserve string contents - review the output, since minifying unusual syntax by pattern-matching alone can occasionally miss an edge case.
More Programming Language Tools
View all 23For HTML and JSON, the dedicated HTML Minifier and JSON Minifier follow those formats' own rules.
What Does This Tool Do?
It makes code smaller by removing comments, line breaks and unnecessary spaces, without changing what the code does. It works on CSS and C-style languages such as JavaScript, PHP, Java and C#. Quoted strings are copied exactly as written, so spaces and comment-like text inside them are safe.
Why Use This Tool?
It is handy for one-off jobs where no build tool is set up: a snippet for a CMS field, an embed code, an email template's CSS, or a quick check of how much smaller a file could be.
How to Use It
- Paste your code.
- Click Minify.
- Copy the result - the size saving is shown above it.
Limitations
It removes whitespace and comments only; it does not shorten variable names or remove unused code. A line break between two statements is kept when removing it could change how JavaScript is read, so the output may keep a few line breaks. For HTML and JSON, use the dedicated HTML and JSON minifiers.
Example
CSS such as:
/* buttons */
.btn {
padding: 12px 20px;
border-radius: 8px;
}
minifies to:
.btn{padding:12px 20px;border-radius:8px;}
What It Removes
- Block comments (
/* ... */) and line comments (// ...). - Line breaks, indentation and extra spaces around
{ } ; : ,. - Nothing inside quoted strings - their contents are left untouched.
It works on CSS and C-style code such as JavaScript, PHP, Java and C#. For other formats, use the dedicated tools: the HTML Minifier, the JSON Minifier and, for the safest JavaScript result, the JavaScript Minifier.
When to Minify Here vs in a Build
For a website you maintain, a build step (Vite, webpack, esbuild, Laravel Mix) should minify automatically on every deploy. This tool suits one-off jobs: a snippet for a CMS, an email template, an embed code, or a quick size check. Whatever you choose, server compression (gzip or Brotli) saves even more - check yours with the GZIP Checker.
Make minified code readable again with the Code Beautifier.
Frequently Asked Questions
Explore More Tools
Keep going with related categories and our most used tools.