Code Minifier

Remove comments and whitespace from CSS, JavaScript, and HTML. Basic minification — not full AST-level.

Deep Dive

Minify CSS, JavaScript, and HTML to reduce file sizes for faster web page loading. The tool strips comments, whitespace, and unnecessary characters while preserving functionality. All minification happens client-side — your source code is never sent to a server.

Who uses this?

  • Reducing CSS bundle size before deploying a website
  • Preparing a single-file HTML page for distribution
  • Minimizing inline JavaScript in an email template
  • Learning how build tools like webpack transform code

Examples

Minify CSS

Input

body { margin: 0; padding: 0; /* reset */ }

Output

body{margin:0;padding:0}

Common Errors & Fixes

Minified JavaScript throws a syntax error

Ensure your original JS has no syntax errors before minifying. Run it through a linter first.

CSS variables or custom properties are removed

The tool should preserve CSS custom properties. If not, check that your input uses standard `--variable` syntax.

HTML minifier removes whitespace inside `<pre>` tags

Content inside `<pre>` and `<textarea>` should be preserved. If whitespace is removed, report it or manually add it back.

Expert FAQ

Will minification break my code?

For standard, well-formed code, no. However, code that relies on `arguments.caller`, `Function.name`, or specific whitespace formatting may behave differently after minification.

What is the difference between minification and uglification?

Minification removes whitespace and comments. Uglification also renames variables to shorter names, providing a greater size reduction (and minor obfuscation).

Should I minify my development files?

No. Minify only for production. Keep original source files for development. Use source maps if you need to debug minified code.

Alternatives

Terser (JS)cssnanoHTMLMinifier.com