minify-html
Extremely fast and smart HTML + JS + CSS minifier
What it is and what it does
minify-html is a Python binding to a Rust HTML minifier that compresses HTML, JavaScript, and CSS in a single pass. It uses oxc for JavaScript minification and lightningcss for CSS, designed to outperform other minifiers in both speed and compression effectiveness. The package handles invalid HTML and can preserve templating syntax via configuration flags.
You import the module and call minify() with your HTML string and optional configuration flags (minify_js, minify_css, keep_comments, etc.). All configuration options default to False if omitted. The binding is built with PyO3 and distributed as precompiled wheels for common platforms; no compilation is required on install for supported systems.
Use it for:
- Minify HTML templates in a web build pipeline to reduce payload size before deployment.
- Strip whitespace and optimize embedded CSS/JS in static site generators or template rendering.
- Batch-process HTML files while preserving templating directives like Jinja or Django syntax.
- Reduce HTML response size in a web scraper or HTML processing utility.
- Optimize HTML email templates for smaller file size and faster transmission.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Minifies HTML, JavaScript, and CSS in a single pass using a Rust-based engine with Python bindings, optimized for both speed and compression ratio.
Yes, if you need fast HTML minification with integrated CSS and JS optimization. The permissive MIT license, active repository, and precompiled wheels for common platforms make it low-friction to adopt. Medium install friction only applies if you target uncommon architectures; no known vulnerabilities. Aging maintenance status is a minor concern but not a blocker for a stable utility.
Install
minify-html on PyPI
pip
pip install minify-htmluv
uv add minify-htmlpoetry
poetry add minify-htmlInstalling minify-html
Before you install
Medium install friction due to precompiled wheels for common platforms (Linux x64/ARM64, macOS x64/ARM64, Windows x64) covering Python 3.10–3.12. Last release was 293 days ago; repository is active and not archived, though maintenance status is aging.
License in practice
MIT license is permissive; you may use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install minify-html
import minify_html
minified = minify_html.minify(" <p>Hello</p> ", minify_js=True, minify_css=True)
Verify before relying
- Whether precompiled wheels cover all target deployment platforms beyond documented x64/ARM64 Linux, macOS, Windows x64.
- Performance comparison with other Python HTML minifiers in your specific use case.
- Behavior when minifying HTML with embedded templating syntax beyond documented preservation options.
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | aging — 293 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,437,398/month — #3,897 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: minify_html-0.18.1-cp310-cp310-macosx_10_12_x86_64.whl; minify_html-0.18.1-cp310-cp310-macosx_11_0_arm64.whl; minify_html-0.18.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; minify_html-0.18.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; minify_html-0.18.1-cp310-cp310-musllinux_1_1_aarch64.whl; minify_html-0.18.1-cp310-cp310-musllinux_1_1_x86_64.whl; minify_html-0.18.1-cp310-cp310-win_amd64.whl; minify_html-0.18.1-cp311-cp311-macosx_10_12_x86_64.whl; minify_html-0.18.1-cp311-cp311-macosx_11_0_arm64.whl; minify_html-0.18.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; minify_html-0.18.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; minify_html-0.18.1-cp311-cp311-musllinux_1_1_aarch64.whl; minify_html-0.18.1-cp311-cp311-musllinux_1_1_x86_64.whl; minify_html-0.18.1-cp311-cp311-win_amd64.whl; minify_html-0.18.1-cp312-cp312-macosx_10_12_x86_64.whl; minify_html-0.18.1-cp312-cp312-macosx_11_0_arm64.whl; minify_html-0.18.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; minify_html-0.18.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; minify_html-0.18.1-cp312-cp312-musllinux_1_1_aarch64.whl; minify_html-0.18.1-cp312-cp312-musllinux_1_1_x86_64.whl
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
Flask-MinifyFlask extension that automatically minifies…
permissive · top 15,000 on PyPI
htmlmin2Minifies HTML by removing unnecessary…
permissive · top 5,000 on PyPI
mkdocs-minify-pluginMinifies HTML, JavaScript, and CSS files in…
permissive · top 5,000 on PyPI
python-minifierTransforms Python source code into compact,…
permissive · top 15,000 on PyPI
django-htmlminMinifies HTML by removing whitespace and…
permissive · top 5,000 on PyPI
rjsminrjsmin minifies JavaScript code by removing…
permissive · top 5,000 on PyPI
css-html-js-minifyMinifies CSS, HTML, and JavaScript files or…
copyleft · top 15,000 on PyPI
stretchablestretchable is a Python layout engine that…
permissive · top 15,000 on PyPI
htmlminMinifies HTML by removing unnecessary…
permissive · top 5,000 on PyPI
jsbeautifierBeautifies, unpacks, and deobfuscates…
permissive · top 5,000 on PyPI