A highly configurable, well-tested JavaScript-based HTML minifier with lint-like capabilities. Current stable version is 0.6.9-patch1 (released in 2016). It reduces HTML size by removing comments, whitespace, redundant attributes, etc. Compared to alternatives like Will Peavy's minifier or htmlcompressor.com, it consistently achieves smaller output sizes across multiple real-world websites. The tool offers a comprehensive set of options and can be used via CLI or programmatic API. It supports Node.js >=0.10.0 and is available on npm.
npm install html_minNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Minifies HTML by removing comments and collapsing whitespace, with JS and CSS minification enabled.
Use conservativeCollapse or ignore custom elements via options
Ensure JS is valid; use a custom minify function for graceful handling
Use exact option names from documentation
Use const minify = require('html-minifier'); or const { minify } = require('html-minifier');Run 'npm install html-minifier' and check package.json
Ensure html input is a non-null string
No dependency data recorded yet.