Paste your code to strip comments, collapse whitespace, and reduce file size. Runs entirely in your browser — nothing is sent to any server.
Minification is the process of removing all unnecessary characters from source code — including whitespace, comments, and redundant syntax — without changing its functionality. The result is a smaller file that loads faster in the browser and reduces bandwidth usage for both servers and visitors.
Modern web performance best practices require minified assets. Tools like Webpack, Rollup, and Vite do this automatically during a build step, but this tool lets you minify individual files instantly without any build setup.
A CSS minifier removes block comments (/* ... */), strips unnecessary whitespace around selectors, properties, and values, eliminates redundant semicolons before closing braces, and collapses all multi-line rules onto a single line. The resulting file is functionally identical to the original but can be 30–80% smaller depending on how much whitespace and commentary was in the source.
/* ... */ block comments:, ;, {, and }JavaScript minification is more complex than CSS because whitespace inside string literals must be preserved. This tool removes single-line (//) and multi-line (/* */) comments, collapses unnecessary whitespace between tokens, and strips redundant newlines — all while correctly handling single-quoted, double-quoted, and template literal strings so their contents are never altered.
// single-line and /* multi-line */ commentsHTML minification removes HTML comments, collapses sequences of whitespace between tags to a single space, and removes optional closing tags for common void and structural elements. The page renders identically in all modern browsers.
<!-- ... --> HTML comments<li>, <dt>, <dd>, <p>, <tr>, <td>, <th>CSS minification is straightforward: the language has no string literals that could be confused with whitespace, so aggressive collapsing is safe. JavaScript is trickier because whitespace inside strings, regular expressions, and template literals must be left exactly as written. This tool uses a character-by-character state machine that tracks whether the parser is inside a string or comment before making any whitespace decisions, making it safe for real-world JS code.
For production deployments, consider also enabling Gzip or Brotli compression on your server. Minification and compression are complementary: minification reduces the number of unique characters, which makes compression more effective, typically achieving 60–90% total size reduction compared to the original source.
\n