Fast command-line HTML minifier — works on any HTML, with special support for Razor and Web Forms views. Parallel processing, safe preservation of <pre>/<code>/Knockout blocks, and easy MSBuild/CI integration.
See the codeA fast and efficient command-line tool to minify your HTML, Razor views, and Web Forms views. Reduce file sizes, improve load times, and deliver a better user experience by removing unnecessary whitespace and comments from your HTML files.
<pre>, <textarea>, and <code> tags, and normalises attribute whitespaceEvery run finishes with a clear, colour-coded summary - per-file savings plus overall compression, throughput, and elapsed time:
See INSTALL.md for release downloads, prerequisites, installation, and instructions for obtaining and building the source.
Transform verbose HTML into compact, optimized code:
<h2>
Admin Menu</h2>
<ul>
<li>@Html.ActionLink("Edit blog entries", "List", "Admin")</li>
<li>@Html.ActionLink("View Comments", "CommentList", "Admin")</li>
<li>@Html.ActionLink("Clear Cache", "ClearCache", "Admin")</li>
</ul>
<h2> Admin Menu</h2><ul><li>@Html.ActionLink("Edit blog entries", "List", "Admin")</li><li>@Html.ActionLink("View Comments", "CommentList", "Admin")</li><li>@Html.ActionLink("Clear Cache", "ClearCache", "Admin")</li></ul>
View all available options:
HtmlMinifier.exe --help
Check the version:
HtmlMinifier.exe --version
Minify all HTML files in a folder (including subfolders):
HtmlMinifier.exe "C:\Folder"
Restrict the maximum number of characters per line:
HtmlMinifier.exe "C:\Folder" "60000"
For frameworks that rely on HTML comments (Angular, Knockout, etc.), preserve them:
HtmlMinifier.exe "C:\Folder" ignorehtmlcomments
Keep JavaScript comments in your code:
HtmlMinifier.exe "C:\Folder" ignorejscomments
Specifically preserve Knockout.js comments:
HtmlMinifier.exe "C:\Folder" ignoreknockoutcomments
HtmlMinifier.exe "C:\Folder\fld1" "C:\Folder\fld2"
HtmlMinifier.exe "C:\Folder\file1.html" "C:\Folder\file2.html"
Integrate HTML Minifier into your build process for automatic minification during deployment. Check out this detailed guide on using HTML Minifier with MSBuild.
The following content is never altered by minification:
<pre>, <textarea>, <code> tags — internal whitespace is kept exactly as-is<!--[if IE]>, <!--[if !IE]><!-->, and <!--<![endif]--> patterns are all preserved#include virtual comments — ASP.NET server-side includes are left intact<!-- ko --> / <!-- /ko --> are preserved when ignoreknockoutcomments is set@model, @using, @inherits are kept and correctly re-arrangedContributions are welcome. Read CONTRIBUTING.md for the development setup, coding standards, acceptance requirements, and pull request process.
To report a bug or propose an enhancement, follow SUPPORT.md.
Copyright (C) Dean Hume 2013 - 2026
Released under the MIT License
Made with ❤️ by Dean Hume
Fast command-line HTML minifier — works on any HTML, with special support for Razor and Web Forms views. Parallel processing, safe preservation of <pre>/<code>/Knockout blocks, and easy MSBuild/CI integration.
See the codeA fast and efficient command-line tool to minify your HTML, Razor views, and Web Forms views. Reduce file sizes, improve load times, and deliver a better user experience by removing unnecessary whitespace and comments from your HTML files.
<pre>, <textarea>, and <code> tags, and normalises attribute whitespaceEvery run finishes with a clear, colour-coded summary - per-file savings plus overall compression, throughput, and elapsed time:
See INSTALL.md for release downloads, prerequisites, installation, and instructions for obtaining and building the source.
Transform verbose HTML into compact, optimized code:
<h2>
Admin Menu</h2>
<ul>
<li>@Html.ActionLink("Edit blog entries", "List", "Admin")</li>
<li>@Html.ActionLink("View Comments", "CommentList", "Admin")</li>
<li>@Html.ActionLink("Clear Cache", "ClearCache", "Admin")</li>
</ul>
<h2> Admin Menu</h2><ul><li>@Html.ActionLink("Edit blog entries", "List", "Admin")</li><li>@Html.ActionLink("View Comments", "CommentList", "Admin")</li><li>@Html.ActionLink("Clear Cache", "ClearCache", "Admin")</li></ul>
View all available options:
HtmlMinifier.exe --help
Check the version:
HtmlMinifier.exe --version
Minify all HTML files in a folder (including subfolders):
HtmlMinifier.exe "C:\Folder"
Restrict the maximum number of characters per line:
HtmlMinifier.exe "C:\Folder" "60000"
For frameworks that rely on HTML comments (Angular, Knockout, etc.), preserve them:
HtmlMinifier.exe "C:\Folder" ignorehtmlcomments
Keep JavaScript comments in your code:
HtmlMinifier.exe "C:\Folder" ignorejscomments
Specifically preserve Knockout.js comments:
HtmlMinifier.exe "C:\Folder" ignoreknockoutcomments
HtmlMinifier.exe "C:\Folder\fld1" "C:\Folder\fld2"
HtmlMinifier.exe "C:\Folder\file1.html" "C:\Folder\file2.html"
Integrate HTML Minifier into your build process for automatic minification during deployment. Check out this detailed guide on using HTML Minifier with MSBuild.
The following content is never altered by minification:
<pre>, <textarea>, <code> tags — internal whitespace is kept exactly as-is<!--[if IE]>, <!--[if !IE]><!-->, and <!--<![endif]--> patterns are all preserved#include virtual comments — ASP.NET server-side includes are left intact<!-- ko --> / <!-- /ko --> are preserved when ignoreknockoutcomments is set@model, @using, @inherits are kept and correctly re-arrangedContributions are welcome. Read CONTRIBUTING.md for the development setup, coding standards, acceptance requirements, and pull request process.
To report a bug or propose an enhancement, follow SUPPORT.md.
Copyright (C) Dean Hume 2013 - 2026
Released under the MIT License
Made with ❤️ by Dean Hume