Code Minifier

Minify JavaScript, CSS or HTML — comments and whitespace stripped, bytes saved reported.

Minify JavaScript, CSS or HTML online: comments and whitespace stripped, byte savings reported. Auto-detect picks the language; CSS is minified aggressively, JS conservatively so string literals stay intact. Everything runs in your browser.

How to minify JavaScript, CSS, or HTML

Paste code, choose JavaScript, CSS, HTML, or Auto-detect, then select Minify. The tool removes comments and unnecessary whitespace while reporting the original size, output size, and percentage saved.

This is a conservative source transformation, not a full compiler optimization pass. Test minified output in your application before deploying it, especially when processing unusual syntax or embedded content.

Original: 0 bytes Minified: 0 bytes Saved: 0%

Example

CSS input (83 characters):

/* header */
body {
  margin: 0;
  color: #333333;
}

.btn:hover {
  color: red;
}

Minified (49 characters, 41% smaller): body{margin:0;color:#333333}.btn:hover{color:red}. JavaScript works the same way: function add(a, b) { return a + b; // sum } spread over four lines with a comment becomes function add(a,b){return a+b;}. Variable names are kept; it removes comments and whitespace but doesn't rename or rewrite code.

How to use the Code Minifier

  1. Paste your code and pick the language (or leave it on auto-detect).
  2. Hit Minify — the output plus bytes-saved stats appear instantly.
  3. Copy the minified output into your production bundle.

Frequently asked questions

How do I minify JavaScript online?

Paste the code above and hit Minify. The tool strips comments and collapses whitespace outside string literals, keeping your code safe to run.

Does the minifier rename variables?

No — it performs safe minification only (comments and whitespace). For full minification with renaming, use a build tool like esbuild or terser.

How do I minify CSS?

Paste CSS and choose CSS — comments are removed and whitespace around braces, colons and semicolons is collapsed.

Does HTML minification break <pre> blocks?

No — pre, textarea, script and style blocks are protected, so their content keeps its original formatting.

Fun facts about Code Minifier