HTMLMinifier is a highly configurable, well-tested JavaScript library for minifying HTML code. The current stable version is 3.5.1-patch1, released as a maintenance patch. It offers extensive options for compression, including removing comments, collapsing whitespace, and minifying inline CSS/JS. Unlike simpler minifiers, HTMLMinifier provides fine-grained control over every aspect of HTML compression and has been battle-tested on major websites like Google, Amazon, and Wikipedia. It supports both Node.js and CLI usage, with a large ecosystem of integrations (Grunt, Gulp, etc.). Active development has slowed, but it remains stable and widely used.
npm install html-minifier-papandreouNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Minifies a simple HTML snippet by removing extra whitespace, comments, and attribute quotes.
Use options as documented in 3.x; ensure Node.js >=4.
Use 'removeEmptyOrBlankAttributes' instead.
Set 'removeComments' to false and 'minifyJS'/'minifyCSS' to false if preserving such content is critical.
Use 'conservativeCollapse' or set 'collapseWhitespace' to false for content-sensitive whitespace.
Use camelCase option names consistently.
Use import { minify } from 'html-minifier' or const { minify } = require('html-minifier').Run npm install html-minifier and check module path.
Refer to the documentation for valid options and their types.
No dependency data recorded yet.