django-htmlmin
HTML minifier for Python frameworks (not only Django, despite the name).
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-htmlminuv
uv add django-htmlminpoetry
poetry add django-htmlminInstalling 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
Tags
More HTML packages
MarkupSafe provides a text object that escapes…
permissive · top 100 on PyPI
Jinja2Jinja2 is a templating engine that renders…
permissive · top 100 on PyPI
beautifulsoup4Beautiful Soup parses HTML and XML documents…
permissive · top 100 on PyPI
lxmllxml provides Python bindings to libxml2 and…
permissive · top 1,000 on PyPI
docutilsDocutils converts plaintext documentation in…
unclear · top 1,000 on PyPI
MarkdownConverts Markdown text to HTML using a Python…
permissive · top 1,000 on PyPI
htmlmin2Minifies HTML by removing unnecessary…
permissive · top 5,000 on PyPI
htmlminMinifies HTML by removing unnecessary…
permissive · top 5,000 on PyPI
Flask-MinifyFlask extension that automatically minifies…
permissive · top 15,000 on PyPI
minify-htmlMinifies HTML, JavaScript, and CSS in a single…
permissive · top 5,000 on PyPI
mkdocs-minify-pluginMinifies HTML, JavaScript, and CSS files in…
permissive · top 5,000 on PyPI
JSON_minifyMinifies JSON by removing whitespace and…
permissive · top 15,000 on PyPI
python-minifierTransforms Python source code into compact,…
permissive · top 15,000 on PyPI
rcssminRCSSmin minifies CSS by removing spaces,…
permissive · top 5,000 on PyPI
css-html-js-minifyMinifies CSS, HTML, and JavaScript files or…
copyleft · top 15,000 on PyPI
rjsminrjsmin minifies JavaScript code by removing…
permissive · top 5,000 on PyPI