Code Minifier
Minify JavaScript, CSS, and HTML to reduce file size and improve page load performance.
How to Use the Code Minifier
Select the code type (JavaScript, CSS, or HTML), paste your code into the input field, and see the minified output instantly. The tool shows the original size, minified size, and percentage savings.
Features
- JavaScript Minification - Variable mangling, dead code elimination, ES6+ support
- CSS Minification - Shorthand optimization, color compression, duplicate removal
- HTML Minification - Whitespace removal, comment stripping, inline CSS/JS minification
- Size Comparison - See original vs minified size and savings percentage
- Copy Output - One-click copy of minified code
Works great with the JSON Formatter for formatting minified JSON and Diff Checker to compare before and after.
What is Code Minification?
Minification is the process of removing all unnecessary characters from source code without changing its functionality. This includes removing whitespace, newlines, comments, and shortening variable names.
Benefits of Minification
- Faster page loads - Smaller files download faster
- Lower bandwidth costs - Less data transferred
- Better caching - Smaller cache footprint
- Improved SEO - Page speed is a ranking factor
JavaScript Minification
JavaScript minification includes:
- Whitespace removal - Spaces, tabs, and newlines
- Comment removal - Single and multi-line comments
- Variable mangling - Shortening variable names (a, b, c instead of descriptive names)
- Dead code elimination - Removing unreachable code
- Constant folding - Pre-computing constant expressions
CSS Minification
CSS minification includes:
- Shorthand properties - Combining margin-top/right/bottom/left into margin
- Color optimization - #ffffff becomes #fff
- Zero units - 0px becomes 0
- Duplicate removal - Removing redundant declarations
- Selector optimization - Merging identical selectors
HTML Minification
HTML minification includes:
- Whitespace collapse - Multiple spaces become one
- Comment removal - HTML comments are stripped
- Attribute optimization - Removing optional quotes and values
- Inline minification - Minifying embedded CSS and JavaScript
Frequently Asked Questions
Is my code secure?
Yes! All minification happens entirely in your browser using JavaScript. Your code is never uploaded to any server.
Should I use minified code in development?
No. Use readable, well-commented code during development. Minify only for production deployment. Keep your source files separate from minified output.
How do I debug minified code?
Use source maps. Most build tools generate source maps that let you debug minified code using the original source files.
Does minification affect performance at runtime?
No. Minified code runs identically to the original. The benefit is faster download times, not faster execution.