A fast and stable HTML minifier based on htmlparser2, focused on HTML5 output. Version 2.2.0 is the latest stable release. It offers highly configurable options for removing empty attributes, comments, conditional comments, quotes, CDATA sections, SSI, and spare attributes. It features a pluggable interface and a CLI. Unlike other minifiers like html-minifier, it strictly targets valid HTML output and does not handle inline PHP or template syntax. The library is designed for server-side use only (browser support not yet available).
npm install minimizeNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Basic usage of minimize with synchronous and asynchronous parsing.
Make sure to minify the final HTML output of your templates, not the templates themselves.
Pass options object to the constructor: `new Minize({ empty: true })`Use minimize in Node.js environments, not in browsers.
Use `empty: true` to keep attributes with empty values instead.
Set `cdata: true` in options to preserve CDATA sections.
Use `const Minize = require('minimize')` then `new Minize().parse(html)`Run `npm install minimize` in your project directory.
Add `"esModuleInterop": true` to tsconfig.json or use `import * as Minize from 'minimize'`
Do not parse the result as JSON; it's plain HTML.