A fast command-line tool that minifies HTML, Razor views, and Web Forms — stripping whitespace and comments without breaking your code.
Whitespace, comments, and redundant spacing removed in one pass.
<!-- Navigation menu --> <h2> Admin Menu </h2> <ul> <li> @Html.ActionLink("Edit entries", "List", "Admin") </li> <li> @Html.ActionLink("View Comments", "CommentList", "Admin") </li> </ul>
<h2> Admin Menu</h2><ul><li>@Html.ActionLink("Edit entries", "List", "Admin")</li><li>@Html.ActionLink("View Comments", "CommentList", "Admin")</li></ul>
✓ 55% smaller — no code changes, no risk.
Built to integrate cleanly with your existing .NET build pipeline.
Utilises all available CPU cores to process large directory trees 4–8× faster than single-threaded alternatives.
Preserves Knockout.js <!-- ko --> comments, Angular directives, and IE conditional comments without extra config.
Content inside <pre>, <textarea>, and <code> tags is always preserved exactly as written.
Opt out of individual features — keep HTML comments, JS comments, or Knockout comments with simple flags.
Set a maximum line length to prevent hitting compiler limits (e.g. the 65K character limit in older ASP.NET).
Zero dependencies, single executable. Plug straight into MSBuild, Azure DevOps, or GitHub Actions post-build steps.
Handles @model, @using, and @inherits declarations correctly — they stay on their own lines so the Razor engine never chokes.
Point at a single file, a list of files, or an entire folder tree. Minification happens in-place with detailed reporting.
The minifier knows what not to touch.
<pre> tag contents & whitespace<textarea> contents & whitespace<code> contents & whitespace<!--[if IE]><!-->#include virtual comments<!-- ko --> bindings (opt-in)@model / @using declarationsOne tool, one command. Scale from a single file to an entire project.
# Minify all HTML files in a folder (recursive) $ HtmlMinifier.exe "C:\MyProject\Views" # Minify a single file $ HtmlMinifier.exe "C:\MyProject\Views\Home\Index.cshtml"
# Preserve HTML comments (useful for Angular / Knockout directive comments) $ HtmlMinifier.exe "C:\Views" ignorehtmlcomments # Preserve JavaScript comments $ HtmlMinifier.exe "C:\Views" ignorejscomments # Preserve Knockout.js / comments only $ HtmlMinifier.exe "C:\Views" ignoreknockoutcomments
# Limit output to 60,000 characters per line # Prevents hitting the 65K compiler limit in older ASP.NET $ HtmlMinifier.exe "C:\Views" 60000
# Minify two separate folders $ HtmlMinifier.exe "C:\Project\Views" "C:\Project\Areas" # Minify specific files $ HtmlMinifier.exe "C:\Views\Index.html" "C:\Views\About.html"
<!-- Add to your .csproj to minify on every Release build --> <Target Name="MinifyHtml" AfterTargets="Build" Condition="'$(Configuration)' == 'Release'"> <Exec Command="HtmlMinifier.exe "$(WebProjectOutputDir)"" /> </Target>
No runtime, no installer. Just download and run.
Grab the latest HtmlMinifier.exe from the releases page.
Place the executable somewhere on your PATH, or reference it directly from your build scripts.
Point it at a file or folder: HtmlMinifier.exe "C:\Views" and you're done.