skillfed

minify-html

Extremely fast and smart HTML + JS + CSS minifier

minify-html v0.18.1 1.4M downloads/30d#3,897 on PyPI1,165
Permissive license MIT AGING released

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-html

uv

uv add minify-html

poetry

poetry add minify-html

Installing 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

html minifier pythonminify html css jsfast html compressionhtml minification toolreduce html file sizehtml css js minifierweb asset minification
html-minificationrust-bindingbuild-tool

More HTML packages