⚡ Open Source · MIT License

Ship smaller HTML,
faster pages.

A fast command-line tool that minifies HTML, Razor views, and Web Forms — stripping whitespace and comments without breaking your code.

↓ Download Latest ★ View on GitHub
8 Supported file types
4–8× Faster with parallel processing
10+ Years in production
MIT Free & open source

See the difference

Whitespace, comments, and redundant spacing removed in one pass.

Before  4,218 bytes
<!-- Navigation menu -->
<h2>
    Admin Menu
</h2>
<ul>
    <li>
        @Html.ActionLink("Edit entries",
            "List", "Admin")
    </li>
    <li>
        @Html.ActionLink("View Comments",
            "CommentList", "Admin")
    </li>
</ul>
        
After  1,876 bytes
<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.

Everything you need,
nothing you don't.

Built to integrate cleanly with your existing .NET build pipeline.

Parallel Processing

Utilises all available CPU cores to process large directory trees 4–8× faster than single-threaded alternatives.

🔧

Framework Aware

Preserves Knockout.js <!-- ko --> comments, Angular directives, and IE conditional comments without extra config.

🛡️

Safe by Default

Content inside <pre>, <textarea>, and <code> tags is always preserved exactly as written.

🎯

Selective Minification

Opt out of individual features — keep HTML comments, JS comments, or Knockout comments with simple flags.

📐

Line Length Control

Set a maximum line length to prevent hitting compiler limits (e.g. the 65K character limit in older ASP.NET).

🔄

CI/CD Ready

Zero dependencies, single executable. Plug straight into MSBuild, Azure DevOps, or GitHub Actions post-build steps.

✂️

Razor Support

Handles @model, @using, and @inherits declarations correctly — they stay on their own lines so the Razor engine never chokes.

📁

Flexible Input

Point at a single file, a list of files, or an entire folder tree. Minification happens in-place with detailed reporting.

Always preserved

The minifier knows what not to touch.

<pre> tag contents & whitespace
<textarea> contents & whitespace
<code> contents & whitespace
IE conditional comments <!--[if IE]>
Downlevel-revealed conditionals <!-->
ASP.NET #include virtual comments
Knockout.js <!-- ko --> bindings (opt-in)
Razor @model / @using declarations
Attribute values (whitespace normalised)
UTF-8 BOM in output files

Simple CLI, powerful options.

One 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>

Up and running in minutes.

No runtime, no installer. Just download and run.

1

Download the release

Grab the latest HtmlMinifier.exe from the releases page.

2

Add to your PATH

Place the executable somewhere on your PATH, or reference it directly from your build scripts.

3

Run it

Point it at a file or folder: HtmlMinifier.exe "C:\Views" and you're done.