NUglify is a HTML, JavaScript and CSS minification Library for .NET (fork of AjaxMin + new features)
C# JavaScript CSS
Clone or download
xoofx Merge pull request #51 from samjudson/master
Test for ES2015 and ES2017 valid minification
Latest commit fa44e61 May 13, 2018

NUglify Build status NuGet

NUglify provides minify and compression methods for CSS, JavaScript and HTML files.

This repository is a fork of the Microsoft Ajax Minifier + additional features (e.g: HTML compressor)


This project is an attempt to keep alive the original AjaxMin project developed by Ron Logan & contributors. I (xoofx) highly invite people to help to fix issues they find in this project, as I can't afford myself to be the sole maintainer of this project. In other words, Pull Requests (PR) are much welcome and most likely the only way for you to get your issue fixed and to help to keep this project alive. Thank you!


  • JS minification (from AjaxMin)
  • Css minification (from AjaxMin)
  • HTML minification (!!New and Exclusive!!)
    • Can help to reduce by 5-10% a standard HTML document
    • Supports several minifications methods: remove comments, collapse whitespaces, remove optional tags (p, li...), remove quoted attributes, decode HTML entities, compress inline style and script using NUglify
    • No regex involved, full HTML parser
    • Supports HTML5, works best on valid HTML documents (but can still work on invalid documents)
    • Similar to the popular html-minifier in JS
    • Super fast and GC friendly parser and minifier, 10x times faster than existing html compressor for .NET
    • Method Uglify.HtmlToText that allows to extract the text from an HTML document
  • Compatible with NET3.5, NET4.0+ and CoreCLR (netstandard1.3+)

NOTE: The repository is under migration/refactoring. See the Background section below for more information.


NUglify is available as a NuGet package: NuGet


The main entry point for the API is the Uglify class:

For JavaScript:

var result = Uglify.Js("var x = 5; var y = 6;");
Console.WriteLine(result.Code);   // prints: var x=5,y=6

For Css:

var result = Uglify.Css("div { color: #FFF; }");
Console.WriteLine(result.Code);   // prints: div{color:#fff}

For Html:

var result = Uglify.Html("<div>  <p>This is <em>   a text    </em></p>   </div>");
Console.WriteLine(result.Code);   // prints: <div><p>This is <em>a text</em></div>

Extract text from Html:

var result = Uglify.HtmlToText("<div>  <p>This is <em>   a text    </em></p>   </div>");
Console.WriteLine(result.Code);   // prints: This is a text


The original documentation of the project is available here


You may wonder why this fork? Here are a few reasons:

  • Ron Logan announced that he is no longer able to maintain this project here
  • While ASP.NET 5.0+ is now relying on the node.js ecosystem for its client side tooling (e.g: minify), NUglify is still useful in scenarios where we need to access this tooling from a .NET application (not necessarily an ASP one) without having to install another developer platform. I can't believe that Ajaxmin could be left behind while it is still valuable!
  • The original code was also hosted on codeplex making it a much less appealing code source platform to collaborate compare to github.
  • It was not possible to keep the history of the commits, as the Ajaxmin SVN codeplex seems to be completely down
  • I wanted the library to be compatible with CoreCLR/dotnet-cli scenarios
  • I may also take the time to cleanup a bit the code. See the Status section below

NOTE: This is an open-source project and I don't claim to be the (only) maintainer of this project, so contributors and PR are much welcome!


  • Migrate code from codeplex
  • Port code to xproj + project.json for .NET3.5, .NET4.x+ and NETCore
  • Rename namespaces
  • Rename files and put them in a single class per file as much as possible
  • Publsih a nuget package
  • Add HTML compressor/minify
  • Try to evaluate a some point if we couldn't collaborate with a project like Jint to leverage on a common JavaScript parser infrastructure
  • Try to evaluate to leverage on AngleSharp for the HTML/Css minification


This software is released under the BSD-Clause 2 license. The original Microsoft Ajax Minifier was released under the Apache 2.0 license


Microsoft Ajax Minifier was created and maintained by Ron Logan, with contributions from Eugene Chigirinskiy, Rafael Correa, Kristoffer Henriksson, and Marcin Dobosz.

Nuglify was ported and refactored to github by Alexandre Mutel aka xoofx


The logo Monster is by Joel McKinney from the Noun Project