skillfed

django-htmlmin

HTML minifier for Python frameworks (not only Django, despite the name).

django-htmlmin v0.11.0 906.3K downloads/30d#4,759 on PyPI
Permissive license Abandoned released

What it is and what it does

django-htmlmin is an HTML minifier that strips whitespace, newlines, and optionally comments from HTML markup to reduce payload size. It integrates with Django via middleware or decorators, works standalone with other Python web frameworks via a direct function call, and includes a command-line tool for static files. The middleware can be configured to minify selectively by URL pattern and respects Django's DEBUG setting by default.

The package has no runtime dependencies and is lightweight, but it is abandoned: the last release was 2019-03-18, and the declared support covers only Django 1.11–2.1 and Python 2.7–3.7—all now end-of-life. While the minification logic itself may still work, there is no active maintenance, no testing against modern versions, and no guarantee of compatibility with current Django or Python releases.

Use it for:

  • Reduce HTML response size in production Django deployments by automatically minifying rendered templates via middleware.
  • Minify static HTML files in build or deployment scripts using the command-line tool without a web framework.
  • Selectively minify specific views by wrapping them with the html_minify() function.
  • Exclude sensitive URLs from minification using regex patterns in EXCLUDE_FROM_MINIFYING.
  • Preserve HTML comments during minification by setting KEEP_COMMENTS_ON_MINIFYING to True.

Worth the install?

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

Minifies HTML by removing whitespace and comments, reducing response size for faster client-side load times. Works as Django middleware, a decorator, a standalone function, or a command-line tool.

No. The package is abandoned (no releases since 2019-03-18) and its declared support covers only obsolete Django and Python versions. While the core minification logic may still function, there is no active maintenance, no testing against modern frameworks, and no assurance of correctness or security. For a maintained alternative, consider a current web framework's built-in optimization features.

Install

django-htmlmin on PyPI

pip

pip install django-htmlmin

uv

uv add django-htmlmin

poetry

poetry add django-htmlmin

Installing django-htmlmin

Before you install

High install friction: the package is abandoned (last release 2019-03-18, no activity for 2706 days). Classifiers list Django 1.11–2.1 and Python 2.7–3.7, all now unsupported. No runtime dependencies, but compatibility with modern Django and Python versions is unverified.

License in practice

Distributed under BSD-style license (permissive). No restrictions on commercial or private use, but you should verify the LICENSE file matches your compliance requirements.

Quickstart

# Django middleware setup
MIDDLEWARE_CLASSES = (
    'htmlmin.middleware.HtmlMinifyMiddleware',
    'htmlmin.middleware.MarkRequestMiddleware',
)
HTML_MINIFY = True

# Or standalone function
from htmlmin.minify import html_minify
minified = html_minify('<div>  content  </div>')

Package is abandoned and untested against modern Django and Python versions. Compatibility not guaranteed.

Verify before relying

  • Whether the package works with Django versions after 2.1.
  • Whether the package works with Python versions after 3.7.
  • Whether minification output is correct for HTML 5 edge cases.
  • Whether the command-line tool is still functional and discoverable after installation.

Package facts

License not declared (permissive)
Python support not specified
Install friction high — source build required
Runtime dependencies none
Maintenance abandoned — 2,706 days since the last release
First released
Downloads 906,300/month — #4,759 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: django-htmlmin-0.11.0.tar.gz

Keywords: django, html, minifier, minify

Development Status :: 5 - Production/StableFramework :: DjangoFramework :: Django :: 1.11Framework :: Django :: 2.0Framework :: Django :: 2.1Intended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Topic :: Text Processing :: Markup :: HTML

Tags

html minifier pythondjango html minification middlewarereduce html file sizehtml whitespace removalhtml minify command linestatic site html compressionhtml payload optimization
abandonedhtml-optimizationlegacy-django

More HTML packages