{"id":41244,"library":"html-minifier-papandreou","title":"HTMLMinifier","description":"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.","status":"maintenance","version":"3.5.1-patch1","language":"javascript","source_language":"en","source_url":"https://github.com/kangax/html-minifier","tags":["javascript","cli","compress","compressor","css","html","htmlmin","min"],"install":[{"cmd":"npm install html-minifier-papandreou","lang":"bash","label":"npm"},{"cmd":"yarn add html-minifier-papandreou","lang":"bash","label":"yarn"},{"cmd":"pnpm add html-minifier-papandreou","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM or CJS are both supported; default export is an object with minify method.","wrong":"const minify = require('html-minifier').minify","symbol":"minify","correct":"import { minify } from 'html-minifier'"},{"note":"Default import is the module itself; no named export 'HTMLMinifier' exists.","wrong":"const { HTMLMinifier } = require('html-minifier')","symbol":"HTMLMinifier","correct":"import htmlMinifier from 'html-minifier'"},{"note":"minify is a named export, not the default.","wrong":"import minify from 'html-minifier'","symbol":"minify (as a function)","correct":"import { minify } from 'html-minifier'"}],"quickstart":{"code":"import { minify } from 'html-minifier';\nconst result = minify('<p>  Hello World  </p>', {\n  removeAttributeQuotes: true,\n  collapseWhitespace: true,\n  minifyCSS: true,\n  removeComments: true\n});\nconsole.log(result); // '<p>Hello World</p>'","lang":"typescript","description":"Minifies a simple HTML snippet by removing extra whitespace, comments, and attribute quotes."},"warnings":[{"fix":"Use options as documented in 3.x; ensure Node.js >=4.","message":"Version 3.x dropped support for Node.js <4, and option names changed significantly from 2.x.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Use 'removeEmptyOrBlankAttributes' instead.","message":"The 'removeEmptyAttributes' option is deprecated and may be removed in a future version.","severity":"deprecated","affected_versions":">=3.5.0"},{"fix":"Set 'removeComments' to false and 'minifyJS'/'minifyCSS' to false if preserving such content is critical.","message":"When minifying inline CSS/JS, the minifier may break scripts that rely on specific spacing or comments (e.g., IE conditional comments).","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"Use 'conservativeCollapse' or set 'collapseWhitespace' to false for content-sensitive whitespace.","message":"The 'collapseWhitespace' option may collapse whitespace inside <pre> tags despite the spec, causing unexpected results.","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"Use camelCase option names consistently.","message":"Using the CLI with '--remove-attribute-quotes' is deprecated in favor of '--removeAttributeQuotes'.","severity":"deprecated","affected_versions":">=3.5.0"}],"env_vars":null,"search_vec":"'3.5.1':21 'activ':88 'amazon':69 'aspect':54 'battl':62 'battle-test':61 'cli':77,100 'code':15 'collaps':37 'comment':36 'compress':33,57,101 'compressor':102 'configur':6 'control':51 'css':103 'css/js':42 'current':17 'develop':89 'ecosystem':82 'etc':87 'everi':53 'extens':30 'fine':49 'fine-grain':48 'googl':68 'grain':50 'grunt':85 'gulp':86 'high':5 'html':14,56,104 'htmlmin':105 'htmlminifi':1,2,46 'includ':34 'inlin':41 'integr':84 'javascript':10,99 'larg':81 'librari':11 'like':67 'mainten':26 'major':65 'min':106 'minifi':13,40,45 'node.js':75 'offer':29 'option':31 'patch':27 'patch1':22 'provid':47 'releas':23 'remain':94 'remov':35 'simpler':44 'slow':91 'stabl':18,95 'support':73 'test':9,63 'unlik':43 'usag':78 'use':98 'version':19 'websit':66 'well':8 'well-test':7 'whitespac':38 'wide':97 'wikipedia':71","created_at":"2026-06-04T18:51:28.520456+00:00","updated_at":"2026-06-04T18:51:28.520456+00:00","problems":[{"fix":"Use import { minify } from 'html-minifier' or const { minify } = require('html-minifier').","cause":"Incorrect import: default import does not export a function directly.","error":"TypeError: htmlMinifier is not a function"},{"fix":"Run npm install html-minifier and check module path.","cause":"Package not installed or incorrectly referenced.","error":"Error: Cannot find module 'html-minifier'"},{"fix":"Refer to the documentation for valid options and their types.","cause":"Using an invalid option name or value not recognized by the minifier.","error":"SyntaxError: Unexpected token (in JSON)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"http://kangax.github.io/html-minifier/","github":"https://github.com/kangax/html-minifier","docs":null,"changelog":null,"pypi":null,"npm":"html-minifier-papandreou","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}