Skip to content
Proyectos

Acerca de

Minificador de HTML modular basado en PostHTML

Desarrollo web y de aplicaciones

Cómo se miden estas cifras

Crecimiento de estrellas medido

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
Recopilando historial

Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.

README.md

Original

htmlnano logo htmlnano

npm version CI

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

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);
    });

Also, you can use it as CLI tool:

node_modules/.bin/htmlnano --help

# STDIN -> STDOUT
cat test.html | node_modules/.bin/htmlnano > test.min.html

# Single file
node_modules/.bin/htmlnano test.html -o test.min.html

# Multiple files / globs (quote globs so htmlnano expands them itself)
node_modules/.bin/htmlnano "dist/**/*.html" --output-dir minified
node_modules/.bin/htmlnano "dist/**/*.html" --in-place

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

Benchmarks

Updated: 2026-11-13

Website Source (KB) html-minifier-terser html-minifier-next htmlnano minify minify-html swc-html
alistapart.com 65 13.9% 25.2% 38.1% 10.1% 11.3% 10.7%
developer.mozilla.org 119 44.4% 43.0% 47.9% 41.2% 41.2% 41.2%
css-tricks.com 183 41.5% 19.6% 25.6% 11.1% 11.3% 12.7%
mastodon.social 45 22.7% 14.4% 14.0% 5.7% 6.9% 7.9%
en.wikipedia.org 259 11.3% 12.6% 12.7% 5.8% 6.1% 6.0%
lafrenchtech.gouv.fr 186 32.5% 70.1% 70.1% 29.9% 30.6% 30.7%
stackoverflow.blog 135 28.8% 7.9% 7.6% 4.6% 5.0% 5.5%
edri.org 85 24.6% 34.7% 33.8% 11.3% 10.6% 11.7%
eff.org 54 18.1% 19.5% 18.3% 13.4% 12.3% 13.0%
w3.org 48 28.7% 28.7% 28.3% 23.7% 23.6% 23.6%
html.spec.whatwg.org 152 1.6% 0.4% 0.4% 0.3% 0.3% 0.3%
un.org 161 23.6% 45.4% 44.9% 19.2% 16.9% 16.7%
apple.com 250 19.7% 11.8% 10.8% 7.6% 6.7% 6.5%
home.cern 292 N/A 23.8% 26.3% 8.1% 9.8% 10.2%
weather.com 455 14.2% 9.7% 9.0% 7.2% 7.0% 7.1%
github.com 513 32.2% 18.1% 18.0% 4.8% 4.3% 4.4%
leanpub.com 523 16.7% 9.0% 9.5% 5.0% 5.4% 5.5%
bbc.co.uk 684 7.8% 8.2% 8.2% 4.7% 6.4% 6.5%
faz.net 1353 7.7% 13.3% 18.1% 4.3% 4.6% 9.2%
tc39.es 7637 9.1% 7.9% 7.3% 6.5% 6.0% 6.1%
Avg. minify rate 21.0% 21.0% 22.2% 11.4% 11.4% 11.9%

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

Explorar proyectos relacionados

Cargando…