Flask-Minify
Flask extension to minify html, css, js and less.
What it is and what it does
Flask-Minify is a Flask extension that intercepts and minifies HTML, JavaScript, CSS, and Less content in your application's responses. It works by parsing outgoing response bodies and reducing their size through whitespace removal and syntax optimization, using pluggable parsers for each content type. By default it minifies all responses unless explicitly bypassed; you can also run it in passive mode to minify only specific decorated routes.
The extension depends on six, flask, lesscpy, htmlminf, jsmin, xxhash, and rcssmin for its core minification logic. It supports caching of minified responses to avoid reprocessing identical content, configurable bypass rules using regex patterns, and optional use of a faster Go-based minifier on Linux systems if the tdewolff-minify package is installed.
Use it for:
- Reduce bandwidth and improve page load times in production Flask applications by automatically minifying all HTML, CSS, and JavaScript responses.
- Selectively minify only specific routes using decorators when you need fine-grained control over which endpoints have minified output.
- Bypass minification for certain endpoints (e.g., API responses or dynamically generated content) using regex patterns to exclude them from processing.
- Cache minified response variations to avoid re-minifying identical content on repeated requests, with configurable limits on cached variations.
- Customize minification behavior per content type by replacing default parsers or providing custom parser implementations for specific tags.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Flask extension that automatically minifies HTML, JavaScript, CSS, and Less output from your application to reduce response size.
Yes. Flask-Minify is actively maintained, has no known vulnerabilities, installs with low friction, and solves a real problem for Flask applications seeking to reduce response size. The MIT license is permissive. Install it if you want automatic minification of HTML, CSS, and JavaScript responses without manual configuration; the decorator and bypass options give you control when you need it.
Install
flask-minify on PyPI
pip
pip install flask-minifyuv
uv add flask-minifypoetry
poetry add flask-minifyInstalling Flask-Minify
Before you install
Low friction install with a pure-Python default setup. Active maintenance with recent releases; last commit 2026-04-13. Optional Go dependency available for Linux systems offers performance improvement but is not required.
License in practice
MIT license permits commercial and private use with minimal restrictions; you must include the license notice in distributions.
Quickstart
pip install Flask-Minify
from flask import Flask
from flask_minify import Minify
app = Flask(__name__)
Minify(app=app, html=True, js=True, cssless=True)
Verify before relying
- Whether the optional Go dependency (tdewolff-minify) is actually available and maintained on PyPI
- Performance impact of minification on typical Flask applications with various response sizes
- Compatibility with Flask versions beyond those implied by the classifiers
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 7 — six, flask, lesscpy, htmlminf, jsmin, xxhash, rcssmin |
| Maintenance | actively maintained — 503 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 88,810/month — #13,704 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: Flask_Minify-0.50-py3-none-any.whl
Keywords: flask, extension, minifer, htmlmin, lesscpy, jsmin, html, js, less, css
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
css-html-js-minifyMinifies CSS, HTML, and JavaScript files or…
copyleft · top 15,000 on PyPI
minify-htmlMinifies HTML, JavaScript, and CSS in a single…
permissive · top 5,000 on PyPI
Flask-AssetsIntegrates asset management into Flask…
permissive · top 15,000 on PyPI
mkdocs-minify-pluginMinifies HTML, JavaScript, and CSS files in…
permissive · top 5,000 on PyPI
django-htmlminMinifies HTML by removing whitespace and…
permissive · top 5,000 on PyPI
htmlmin2Minifies HTML by removing unnecessary…
permissive · top 5,000 on PyPI
lesscpyCompiles LESS stylesheets to CSS using Python,…
permissive · top 15,000 on PyPI
cssminCompresses CSS files by removing unnecessary…
unclear · top 15,000 on PyPI
jsminMinifies JavaScript code by removing…
permissive · top 5,000 on PyPI
csscompressorCompresses CSS by removing unnecessary…
permissive · top 5,000 on PyPI