Introduction
htmlnano is a modular HTML minifier built on top of PostHTML. Inspired by cssnano.
Why htmlnano
htmlnano is designed for production HTML optimization with a modular architecture:
- Safe by default: the built-in
safepreset focuses on conservative transforms. - Configurable per module: enable, disable, or tune each transform independently.
- Ecosystem-friendly: use it through the JS API, PostHTML, CLI, or bundler integrations.
- Extensible: optional modules let you include CSS/JS/URL minification as needed.
How it works
htmlnano processes your HTML with an ordered set of modules. Each module handles one concern (for example, comments, whitespace, attributes, inline CSS, or inline JS), so behavior is predictable and easy to tune for your project.
In most setups, the typical flow is:
- Start with a preset (
safe,ampSafe, ormax). - Override only the modules you care about.
- Run htmlnano as the final PostHTML step.
Next steps
- Learn integration patterns in Usage.
- See config precedence and file-based config in Config.
- Pick a baseline preset in Presets.
- Review module behavior and caveats in Modules.
- Compare size reduction results in Benchmarks.