HTMLMinifier is a JavaScript HTML minifier with many toggles for whitespace, attributes, and embedded CSS or JS. Maintenance moved to github.com/j9t/html-minifier; this tree is deprecated.
Overview
HTMLMinifier shrinks HTML by removing optional tags, collapsing whitespace, trimming attributes, and optionally minifying inline CSS and JavaScript. Most options stay off unless you enable them, which keeps defaults conservative.
The tool parses markup into a tree, applies your chosen transforms, and serializes HTML again. It documents edge cases such as preserving custom comment blocks, SVG handling, and limitations when input markup is partial or invalid.
A web UI exposes the same option set for interactive trials. Command-line usage is supported through the html-minifier npm package.
The original kangax project is deprecated in favor of j9t/html-minifier. Related ecosystem wrappers mentioned in docs include Grunt, Gulp, Koa, Express, and Ruby bindings.
Key features
- Highly configurable minification options
- Optional inline CSS and JS minify
- HTML5 parsing mode
- Whitespace and comment removal
- Custom comment and fragment ignore
- CLI and programmatic Node API
Use cases
- Shrink static HTML templates
- Batch minify build output
- Tune aggressive size reduction
- Compare minifier benchmarks