Introducing The Sweep: OX’s New Live Security Research Series
Register Now
Breaking: The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Read the Report
Are you exposed? Connect your apps in minutes.
Scan your apps free

html-minifier

Latest version: v5.5.2

Overview

Last scanned
3 Dec 2026
Published
3 Dec 2026
npm package Publisher: j9t, kangax
11 Stars
0 Forks
16 Versions
13.3M Downloads
JavaScript Repo language

Scan summary

html-minifier was last scanned on 3 Dec 2026 at version 5.5.2. Risk score 0 of 100. No malicious behavior was detected.

  • Releases: 16 versions; the latest 4 were published within 6 days (28 Nov – 3 Dec 2026).
  • Findings: No rules fired in version 5.5.2.
  • Downloads: 13,294,200 downloads.

Versions

16 versions published
Versions and the rules that fired in each
VersionPublishedStatus
5.5.2 LATEST 3 Dec 2026 No rules fired
5.5.1 2 Dec 2026 No rules fired
5.5.0 30 Nov 2026 No rules fired
5.4.2 28 Nov 2026 Not shown
5.4.1 22 Nov 2026 Not shown

No rules fired in 5.5.2

Findings

Findings for v5.5.2. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.

The score describes 5.5.2; other versions have their own rules, not their own score.

Known vulnerabilities

2 CVEs · last 30 Nov 2026

0 CRITICAL 2 HIGH 0 MEDIUM 0 LOW

Versions

  • ≥ 5.0.1
  • > 4.0.0, < 5.0.1 1 HIGH
  • ≥ 3.1.1, ≤ 4.0.0 2 HIGH
  • < 3.1.1 1 HIGH

Vulnerabilities

  • CVE-2026-140010 High 30 Nov 2026 HTML Minifier Next: Regular expressions in `minify()` cause O(n²) backtracking on ignored and custom-fragment content Fixed in 5.0.1
  • CVE-2022-37620 High 31 Oct 2022 kangax html-minifier REDoS vulnerability No fix yet

README

The publisher’s own README, as collected from the registry.

HTML Minifier

npm version Test status

Your web page optimization precision tool: HTML Minifier (HM) is a highly effective, super-configurable, well-tested HTML minifier, written in JavaScript, that also handles in-document CSS, JavaScript, and SVG minification. Your result: leaner, faster, more sustainable pages (and fewer LLM tokens).

HTML Minifier was originally created by Juriy “kangax” Zaytsev. As of version 5, it’s actively maintained by Jens Oliver Meiert—richer in features, easier to use, and significantly faster (engineering philosophy).

ℹ️ Updating from HTML Minifier 4? Use the HTML Minifier 4 to 5 upgrade guide. Switching from HTML Minifier Next? Use the HTML Minifier Next to HTML Minifier migration guide.

Quick Start

  • Single-file minification: npx html-minifier --preset comprehensive input.html -o output.html
  • Zero-config, in-place minification in the current directory and subdirectories: npx html-minifier --zero (asks for confirmation; preview with --dry)
  • Configuration wizard (beta) in a directory of unminified web pages: npx html-minifier-setup (proposes optimal configuration)
  • Installation guides: Astro · Eleventy · Jekyll · VitePress (your guide?)
  • Manual minification, experimentation, and sample-sharing: HTML Minifier web version

Installation

HTML Minifier is ESM-only and requires Node.js ≥22.13.

For use as a command-line app, use npx:

npx html-minifier --help

For programmatic use, install as a development dependency:

npm i -D html-minifier

General Usage

CLI

Use npx html-minifier --help to check all available options:

Option Description Example
--zero, -z Minify all HTML files in the current directory and its subdirectories in place (except node_modules), using comprehensive settings (standalone, with --dry to preview, or with --tokens—the flag is ignored when combined with other options) npx html-minifier --zero
--input-dir <dir>, -I <dir> Specify an input directory --input-dir=src
--ignore-dir <patterns>, -X <patterns> Exclude directories—relative to input directory—from processing (comma-separated, overrides config file setting) --ignore-dir=libs, --ignore-dir=libs,vendor,node_modules
--output-dir <dir>, -O <dir> Specify an output directory --output-dir=dist
--workers <n>, -w <n> Number of worker threads for multi-file runs; defaults to half the available cores (at most 6) for runs large enough to justify them --workers=4
--input <file>, -i <file> Specify input file (alternative to positional argument; pair with --output for file output) npx html-minifier -i input.html -o output.html
--output <file>, -o <file> Specify output file (reads from --input file argument or STDIN; outputs to STDOUT if not specified) File to file: npx html-minifier input.html -o output.htmlFile to file (explicit): npx html-minifier -i input.html -o output.htmlPipe to file: cat input.html \| npx html-minifier -o output.htmlFile to STDOUT: npx html-minifier input.html
--file-ext <extensions>, -f <extensions> Specify file extension(s) to process (comma-separated, overrides config file setting); defaults to html,htm,shtml,shtm; use * for all files --file-ext=html,php, --file-ext='*'
--preset <name>, -p <name> Use a preset configuration (conservative or comprehensive) --preset=conservative
--config-file <file>, -c <file> Use a configuration file (defaults to html-minifier.config.json in the working directory, if present) --config-file=path/to/config.json
--tokens, -t Add LLM token savings (as per OpenAI’s o200k_base) to the statistics reported npx html-minifier --input-dir=src --output-dir=dist --tokens
--verbose, -v Show detailed processing information (active options, worker thread count, file statistics, and minifier warnings) npx html-minifier --input-dir=src --output-dir=dist --verbose --collapse-whitespace
--dry, -d Dry run: Process and report statistics without writing output (without input, previews --zero) npx html-minifier input.html --dry --collapse-whitespace
Configuration File

You can use a configuration file to specify options. If an html-minifier.config.json file is present in the current working directory—only there; subdirectories (including --input-dir) and parent directories are not searched—the CLI picks it up automatically, with a note on STDERR confirming this. An explicit --config-file takes precedence. (The standalone --zero mode is deliberately config-free and ignores default config files.) The file can be either in JSON format or a JavaScript module that exports the configuration object:

JSON configuration example:

{
  "collapseWhitespace": true,
  "removeComments": true,
  "fileExt": "html,php",
  "ignoreDir": "libs,vendor"
}

For editor support (validation, autocomplete, and inline documentation) in JSON configuration files, reference the JSON Schema that ships with the package:

{
  "$schema": "https://raw.githubusercontent.com/j9t/html-minifier/main/html-minifier.schema.json",
  "collapseWhitespace": true,
  "removeComments": true
}

(If HM is installed locally, you can also use the path ./node_modules/html-minifier/html-minifier.schema.json instead of the URL.)

JavaScript module configuration example (requires "type": "module" in the project’s package.json, or use a .mjs extension):

export default {
  collapseWhitespace: true,
  removeComments: true,
  fileExt: "html,php",
  ignoreDir: ["libs", "vendor"]
};

A module can also hold values JSON cannot express, like regular expressions (e.g., ignoreCustomFragments: [/\{\{[\s\S]*?\}\}/]) and functions (for minifyCSS, minifyJS, and minifyURLs, or in custom SVGO plugins for minifySVG). As functions cannot be passed to worker threads, a run using them minifies in-process.

Node.js
import { minify } from 'html-minifier';

const result = await minify('<p title="example" id="moo">foo</p>', {
  removeAttributeQuotes: true,
  removeOptionalTags: true
});
console.log(result); // `<p title=example id=moo>foo`

(CommonJS consumers can still use dynamic import—const { minify } = await import('html-minifier')—as minify() is async.)

Presets

HTML Minifier provides presets for common use cases. Presets are pre-configured option sets that can be used as a starting point:

  • conservative: Basic minification with whitespace collapsing, comment removal, and removal of select attributes.
  • comprehensive: More advanced minification for better file size reduction, including relevant conservative options plus attribute quote removal, optional tag removal, and more.

To review the specific options set, presets.js lists them in an accessible manner. For output served with Gzip or Brotli, see “Optimizing for Compression” for what to add.

Using presets:

# Via CLI flag
npx html-minifier --preset conservative input.html

# Via config file
npx html-minifier --config-file=path/to/config.json input.html
# where config.json contains `{ "preset": "conservative" }`

# Override preset options
npx html-minifier --preset conservative --remove-empty-attributes input.html

Priority order: Presets are applied first, then config file options, then CLI flags. This allows you to start with a preset and customize as needed.

Options Quick Reference

Most of the options are disabled by default. Experiment and find what works best for you and your project.

Options can be used in config files (camelCase) or via CLI flags (kebab-case with -- prefix). Boolean options generally support both --option-name to enable and --no-option-name to disable, so you can override a preset or config file from the command line. (Exception: Options whose name already starts with no-, such as noNewlinesBeforeTagClose, only expose the --no-… CLI flag.)

OX Radar and Response Center

Find threats in your stack.

OX Radar can check high-priority threats, like critical package CVEs, against your context.

Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.

Where it’s listed

The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).

  • npm html-minifier

References

The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.

Powered by Read the latest findings

Scan your whole stack

Group 1261154050 1
Group 1261154050
 

From OX Research Newsroom

Microsoft's Official agent framework Hijacked
AI & VibeSec

BREAKING: Hijacked Releases of Microsoft’s Official agent-framework Steals Azure and CI Credentials

Copy of Template Design OX Blog (1)
Research

Thousands Of GitHub Accounts Hijacked With wfx-loot CI Secret Stealing Malware Via GitHub Actions & npm

Copy of Template Design OX Blog (2)
Research

NGINX2Root: Five Critical NGINX Flaws Expose Web Servers to Remote Code Execution

Frame 2085668439 (1)
Group 1261154229