htmlmin2

0.1.13 · maintenance · verified Sat Apr 11

An HTML Minifier, `htmlmin2` is a configurable HTML minifier with safety features. It is a fork of the `htmlmin` library, created to address compatibility issues with modern Python versions, particularly Python 3.13+. The current version is 0.1.13, released in March 2023. While functional and widely used, its release cadence is currently stalled.

Warnings

Install

Imports

Quickstart

This example demonstrates how to minify a simple HTML string using the `minify` function. By default, it safely removes unnecessary whitespace and comments, preserving the structure and functionality of the HTML.

from htmlmin import minify

html_input = """
<html>
    <head>
        <title> Hello, World! </title>
    </head>
    <body>
        <p> How are <em>you</em> doing? </p>
    </body>
</html>
"""
minified_html = minify(html_input)
print(minified_html)

view raw JSON →