Socket
Book a DemoInstallSign in
Socket

htmlnano

Package Overview
Dependencies
Maintainers
2
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

htmlnano

Modular HTML minifier, built on top of the PostHTML

latest
Source
npmnpm
Version
2.1.5
Version published
Weekly downloads
345K
-12.88%
Maintainers
2
Weekly downloads
 
Created
Source

htmlnano

npm version CI

Modular HTML minifier, built on top of the PostHTML. Inspired by cssnano.

Benchmarks

WebsiteSource (KB)html-minifier-terserhtml-minifier-nexthtmlnanominifyminify-html
stackoverflow.blog1663.3%3.3%8.3%4.6%4.0%
github.com5413.7%3.7%18.1%7.9%6.2%
en.wikipedia.org2204.6%4.6%4.9%6.2%2.9%
npmjs.com4600.5%0.5%0.9%3.6%0.7%
tc39.es71988.5%8.5%8.7%9.5%9.1%
apple.com1907.6%7.6%12.1%10.5%8.1%
w3.org4918.9%18.9%23.0%24.1%19.9%
weather.com17700.2%0.2%12.1%11.9%0.6%
Avg. minify rate5.9%5.9%11.0%9.8%6.4%

Latest benchmarks: https://github.com/maltsev/html-minifiers-benchmark (updated daily).

Documentation

https://htmlnano.netlify.app

Usage

npm install htmlnano
const htmlnano = require('htmlnano');
const options = {
    removeEmptyAttributes: false, // Disable the module "removeEmptyAttributes"
    collapseWhitespace: 'conservative' // Pass options to the module "collapseWhitespace"
};
// posthtml, posthtml-render, and posthtml-parse options
const postHtmlOptions = {
    sync: true, // https://github.com/posthtml/posthtml#usage
    lowerCaseTags: true, // https://github.com/posthtml/posthtml-parser#options
    quoteAllAttributes: false, // https://github.com/posthtml/posthtml-render#options
};

htmlnano
    // "preset" arg might be skipped (see "Presets" section below for more info)
    // "postHtmlOptions" arg might be skipped
    .process(html, options, preset, postHtmlOptions)
    .then(function (result) {
        // result.html is minified
    })
    .catch(function (err) {
        console.error(err);
    });

More usage examples (PostHTML, Gulp, Webpack): https://htmlnano.netlify.app/next/usage

Keywords

posthtml

FAQs

Package last updated on 19 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts