skillfed

htmlmin2

An HTML Minifier

htmlmin2 v0.1.13 1.3M downloads/30d#4,100 on PyPI137
Permissive license BSD Abandoned released

What it is and what it does

htmlmin2 is a Python library that reduces HTML file size by removing unnecessary whitespace, line breaks, and comments while keeping the markup functional. It's designed for developers who need to optimize HTML output in web applications, static site generators, or build pipelines.

The package has no external runtime dependencies, making it lightweight to install. It supports configurable minification with safety features intended to prevent accidental breakage. However, the project is no longer actively maintained—the last commit was 2021-10-20, and the latest release dates to 2023-03-14. This means you should verify compatibility with your target Python version before relying on it in production.

Use it for:

  • Reduce HTML payload size in web applications before serving to browsers
  • Optimize static HTML files generated by site builders or templating systems
  • Strip comments and whitespace from HTML during a build or deployment pipeline
  • Minify HTML email templates to reduce transmission size
  • Post-process HTML output to reduce bandwidth usage

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Minifies HTML by removing unnecessary whitespace and comments while preserving functionality, with configurable safety features.

Yes, if you need a simple, dependency-free HTML minifier for a stable project. The low install friction and permissive BSD license make it easy to adopt. However, be cautious: the package is abandoned and may not work with Python versions released after 2021. Test thoroughly with your target Python version before relying on it in production.

Install

htmlmin2 on PyPI

pip

pip install htmlmin2

uv

uv add htmlmin2

poetry

poetry add htmlmin2

Installing htmlmin2

Before you install

Installation is straightforward with no runtime dependencies. However, the package is abandoned—last commit was 2021-10-20 and no updates have been released since 2023-03-14, creating a maintenance risk for future Python compatibility.

License in practice

BSD license is permissive, allowing use in both open-source and commercial projects with minimal restrictions. You must include a copy of the license and acknowledge the original author.

Quickstart

pip install htmlmin2

import htmlmin2
minified = htmlmin2.minify('<html>  <body>  Hello  </body>  </html>')

Verify before relying

  • Whether the package works reliably with modern Python versions beyond 3.2
  • What specific safety features are configurable and how they prevent breaking changes
  • Whether a maintained fork or alternative is recommended given the abandoned status

Package facts

License BSD (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance abandoned — 1,249 days since the last release
Last repo commit
First released
Downloads 1,293,344/month — #4,100 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: htmlmin2-0.1.13-py3-none-any.whl

Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 2.7Programming Language :: Python :: 3.2Topic :: Text Processing :: Markup :: HTML

Tags

html minifierreduce html file sizestrip whitespace htmlhtml compressionminify markuphtml optimizationremove html comments
html-optimizationabandoned-but-stable

More HTML packages