HTML/CSS/Javascript to Minimize:

Input to the Minifier is not stored on our server. For details, please see our Privacy Policy

Minimized Output:

Save Minified output

About the Web Minifier

Code minification is the process of removing unnecessary characters from a section of code while leaving the code's original functionality in tact. The end result is a new file which is smaller in size to the original, yet identical from the machine's perspective. Smaller files require less bandwidth, and have shorter load times on the web. This can reduce server resources and lead to a more pleasant user experience which is why minifing files is often cited as a best practice for web developement.

This Web Minifier can minify HTML with embedded PHP, JavaScript and CSS*, as well as pure JavaScript* and CSS*

*The articles linked to describe an earlier version of this minifier, one with slightly less capabilities.

This minifier is designed to accomidate:

Important Details

Minification may seem straight forward, but is desepetively complex. While there are many simple approaches (like condensing white space) that can have a big impact on code size, perfect minification would require the ability to understand code from a functional level, and predict all possible outputs from all possible inputs. In fact, it is mathematically provable that a program to achieve perfect minification cannot exist by reducing it to the Halting Program.

Another Gotcha is that the nature of web languages, especially JavaScript, can often break naive minification tools. If one isn't careful minification can interfear with Automatic Semicolon Insertion, modify string literals and regular expressions, and inadvertently extend comments to include code. In fact, the reason I wrote this Minifier is that I grew tired of using free, open sourse Minifiers that broke my code!

The Minifier can minifying HTML, CSS and JavaScript. Since minification is primarly a benefit for data sent to the client, and PHP is executed sever side, we leave embedded PHP untouched. We also leave string variables untouched.

Assumptions the Minifier makes while Minifying HTML:

To understand why these assumptions are important, please see our article on Minimizing HTML with embedded PHP, JavaScript and CSS.