PHPackages                             axy/min-html - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. axy/min-html

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

axy/min-html
============

Compress HTML

0.1.1(10y ago)3221MITPHPPHP &gt;=5.4.0

Since Oct 24Pushed 8y ago3 watchersCompare

[ Source](https://github.com/axypro/min-html)[ Packagist](https://packagist.org/packages/axy/min-html)[ Docs](https://github.com/axypro/min-html)[ RSS](/packages/axy-min-html/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

axy\\min\\html
==============

[](#axyminhtml)

Compress HTML.

[![Latest Stable Version](https://camo.githubusercontent.com/c7b3be8ddccf2a0621de0e9f0a541a2bb807bc9dec20f4ff5bdc947a1f0abb85/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6178792f6d696e2d68746d6c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/axy/min-html)[![Minimum PHP Version](https://camo.githubusercontent.com/b52c83f3d45755ebcb1e6863ebb202ab192aaf773424369ffdeedae107f027ef/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230352e342d3838393242462e7376673f7374796c653d666c61742d737175617265)](https://php.net/)[![Build Status](https://camo.githubusercontent.com/831265cc5f32a5400437227b6bccdaefa04a71e17ed8e5d9228615a48d9da5f9/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f61787970726f2f6d696e2d68746d6c2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/axypro/min-html)[![Coverage Status](https://camo.githubusercontent.com/cb113b9df898d1e88ce223a418667f565fe2f24578db877c7819c7d90977c139/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f61787970726f2f6d696e2d68746d6c2f62616467652e7376673f6272616e63683d6d617374657226736572766963653d676974687562)](https://coveralls.io/github/axypro/min-html?branch=master)[![License](https://camo.githubusercontent.com/f9c4f023470c2cbb170ae0cc2bd2f8539be49cfc17282d820d1c4f10fbf1b1ce/68747470733a2f2f706f7365722e707567782e6f72672f6178792f6d696e2d68746d6c2f6c6963656e7365)](LICENSE)

- The library does not require any dependencies.
- Tested on PHP 5.4+, PHP 7, HHVM (on Linux), PHP 5.5 (on Windows).
- Install: `composer require axy/min-html`.
- License: [MIT](LICENSE).

### Compression

[](#compression)

Simply removes the indentation at the beginning and end of lines. With some exceptions:

- Indents inside some tags (as `` and ``) are relevant.
- The content of some tags can be handled in a special way (compress for `` and `` for example).

#### Example

[](#example)

The source content:

```

    Test

    var x = 2 + 2;
    console.log(x);

    Test

    This is
    example
    of HTML compression.

    Content of PRE
    is PRE

```

The compressed content:

```

Test
var x=2+2;console.log(x);

Test

This is
example
of HTML compression.

    Content of PRE
    is PRE

```

### API

[](#api)

The library defines the single public class `axy\min\html\HTMLMinifier`.

Methods:

- `__construct(string $content [, array $tags])`
- `run(void): string`
- `getOriginContent(void): string`
- `getCompressedContent(void): string`
- `getTags(void): array`

Static methods:

- `compress(string $content [, array $tags]): string`
- `compressFromFile(string $content [, array $tags]): string`
- `compressFile(string $source, string $destination [, array $tags]): string`
- `getDefaultsTags([array $tags]): array`

#### Example

[](#example-1)

Using static:

```
use axy\min\html\HTMLMinifier;

$source = 'index.html';
$destination = 'index.min.html';

HTMLMinifier::compressFile($source, $destination);
```

Without static:

```
$min = new HTMLMinifier($content);
$min->run();
echo $min->getCompressedContent();
```

Tags
----

[](#tags)

The optional array `tags` specifies how to handle content of the tags.

Defaults is

```
[
    'pre' => true,
    'textarea' => true,
]
```

Argument `$tags` merges with the defaults.

`TRUE` - do not change. Or callback.

```
$tags = [
    'script' => function ($content) {
        return JSMinify::minify($content);
    },
    'textarea' => null, // Remove rule for TEXTAREA
    'style' => true, // Content of STYLE does not change
];

HTMLMinifier::compressFile($source, $destination, $tags);
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~45 days

Total

2

Last Release

3814d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e5b3a2db8d5614167d4510019e3373dbba63c6aade58d38d23f3e7d2e63c3c4a?d=identicon)[axy](/maintainers/axy)

---

Top Contributors

[![vasa-c](https://avatars.githubusercontent.com/u/557081?v=4)](https://github.com/vasa-c "vasa-c (13 commits)")

---

Tags

htmlcompress

### Embed Badge

![Health badge](/badges/axy-min-html/health.svg)

```
[![Health](https://phpackages.com/badges/axy-min-html/health.svg)](https://phpackages.com/packages/axy-min-html)
```

###  Alternatives

[voku/html-min

HTML Compressor and Minifier

1804.7M39](/packages/voku-html-min)[spatie/laravel-html

A fluent html builder

8376.4M72](/packages/spatie-laravel-html)[caxy/php-htmldiff

A library for comparing two HTML files/snippets and highlighting the differences using simple HTML.

21320.9M15](/packages/caxy-php-htmldiff)[yajra/laravel-datatables-html

Laravel DataTables HTML builder plugin

2899.6M48](/packages/yajra-laravel-datatables-html)[wyrihaximus/html-compress

Compress/minify your HTML

841.6M31](/packages/wyrihaximus-html-compress)[tinymce/tinymce

Web based JavaScript HTML WYSIWYG editor control.

1697.5M106](/packages/tinymce-tinymce)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
