Code Minifier - Minify JavaScript, CSS & HTML Online
Minify JavaScript, CSS, and HTML code to reduce file size instantly. See compression ratio and savings — 100% client-side, no upload required.
Frequently Asked Questions
What is code minification?
Code minification is the process of removing unnecessary characters from source code without changing its functionality. This includes removing whitespace, comments, and sometimes shortening variable names. The result is smaller file sizes that load faster in browsers.
Is my code safe when using this tool?
Yes, completely safe. All minification happens 100% in your browser using JavaScript. Your code never leaves your device or gets sent to any server. You can verify this by checking your browser's network tab.
What do the JavaScript options do?
Remove console statements: Removes all console.log, console.warn, etc. Keep function names: Prevents function names from being shortened (useful for debugging). Mangle variable names: Shortens variable names to single characters for maximum compression.
What compression ratio can I expect?
Typical reductions vary by language: JavaScript 40-70% (more with mangling), CSS 20-50%, HTML 10-30%. Results depend on how much whitespace and comments your original code contains.
Will minification break my code?
Proper minification should never break working code. This tool uses industry-standard libraries (Terser, clean-css, html-minifier-terser) that handle edge cases correctly. However, always test minified code before deploying to production.
Code Examples
// Using Terser for JavaScript minification
import { minify } from 'terser';
const code = `
function greet(name) {
console.log('Hello, ' + name);
}
`;
const result = await minify(code, {
compress: true,
mangle: true
});
console.log(result.code);
// Output: function greet(o){console.log("Hello, "+o)}