Code Minifier

Minify HTML, CSS, and JavaScript instantly in your browser. Reduce file size by up to 80% with safe, professional-grade compression.

HTML, CSS & JS Minifier
Input
0 B 0 lines
Minified Output
0 B —
Remove comments
Strip /* */ and // comments
Collapse whitespace
Reduce multiple spaces to one
Remove line breaks
Join lines into single stream
Remove extra spaces
Strip around operators, braces
Remove last semicolons
Drop trailing ; before } (CSS)
Aggressive mode
More risky optimizations
0 B
Original Size
0 B
Minified Size
0%
Size Saved
—
Compression
Safe by design. All minification runs in your browser — your code never leaves your device. Test the minified output before deploying to production.

Why use this code minifier?

Minifying code removes unnecessary characters such as extra spaces, line breaks, and comments without changing the intended output. This can reduce the size of HTML, CSS, and JavaScript files, which means less data needs to be transferred when someone loads your website.

This tool supports HTML, CSS, and JavaScript and applies formatting changes suited to each language. It can be useful when you need to quickly reduce the size of a small code file without setting up a separate build tool.

The minification process runs directly in your browser, so you can paste your code, process it, and copy or download the result from the same page.

How to minify your code

  1. Select the code type you want to minify: HTML, CSS, or JavaScript.
  2. Paste your original code into the input editor.
  3. Choose the available optimization options according to your needs. The default options are suitable for normal minification.
  4. Click Minify or use the displayed keyboard shortcut if available.
  5. Review the generated code and the size reduction shown by the tool.
  6. Click Copy to copy the minified code or download it as a file.
  7. Test the minified file before using it on a live website, especially when aggressive optimization options are enabled.

An example

Suppose you have this CSS code:

/* Header styles */
.site-header {
    background-color: #4f46e5;
    padding: 20px 40px;
    color: white;
}

After minification, it can become:

.site-header{background-color:#4f46e5;padding:20px 40px;color:white}

The unnecessary comment, spaces, and line breaks have been removed while the CSS rules remain the same. The resulting file is smaller and can be used as the production version of the stylesheet.

Code Minifier – FAQ

Yes. All minification runs entirely in your browser — your code is never uploaded, stored, or sent anywhere. You can even disconnect from the internet and it will still work. The minification rules are conservative and won't break valid code.
Minification removes everything that isn't necessary for the code to run: comments, extra whitespace, line breaks, and unnecessary characters. A typical minified file is 40-80% smaller than its original — which means faster page loads and lower bandwidth costs.
Not if done safely. Our minifier protects strings, regular expressions, and content inside <pre>, <textarea>, and inline <script>/<style> blocks. It only removes truly unnecessary characters. That said, always test the minified output before deploying to production — this is standard practice with any minifier.
Minification removes unnecessary characters from the source code itself — the file you save is smaller. Compression (like Gzip) is a transport-layer optimization — the server sends a compressed version and the browser decompresses it on the fly. You should use both: minify your files, then enable Gzip on your server.
It works on most standard JavaScript. Because it uses safe regex-based rules rather than full AST parsing (which would require a heavy library), some edge cases with unusual syntax may be handled conservatively. For complex projects, tools like Terser provide more aggressive optimization — but for everyday use, this tool delivers solid results.
Aggressive mode applies additional optimizations that are slightly riskier: removing units from zero values in CSS (0px → 0), removing quotes from safe font names, and dropping more trailing semicolons. Only enable it if you're prepared to test the output carefully — the default settings are safe for 99% of cases.
This tool handles one file at a time — you select HTML, CSS, or JavaScript and paste the corresponding code. For batch processing of many files, you'd want a build tool like Vite, Webpack, or Gulp, which typically include Terser, cssnano, and html-minifier.
Yes. The minifier only removes things that don't affect how code runs — comments, extra spaces, line breaks, and whitespace around operators. Variables, function names, strings, and logic are preserved exactly. That's why minified code works identically to the original.