PHPackages                             gathercontent/htmldiff - 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. gathercontent/htmldiff

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

gathercontent/htmldiff
======================

Compare two HTML strings

0.2.1(11y ago)11286.5k—7.4%6[3 issues](https://github.com/gathercontent/htmldiff/issues)1MITPHP

Since Apr 25Pushed 11y ago9 watchersCompare

[ Source](https://github.com/gathercontent/htmldiff)[ Packagist](https://packagist.org/packages/gathercontent/htmldiff)[ RSS](/packages/gathercontent-htmldiff/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (4)Used By (1)

Htmldiff
========

[](#htmldiff)

[![Build Status](https://camo.githubusercontent.com/0267f44d4c750fc030e93762d3e76b4f3c9249f81ab76a7ccb4d734654f41e04/68747470733a2f2f7472617669732d63692e6f72672f676174686572636f6e74656e742f68746d6c646966662e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/gathercontent/htmldiff)

Compare two HTML strings. This library converts HTML into a form that can be diffed using the algorithm found in Git or Linux (comparing entire lines of code) to achieve greater accuracy, then decodes it back into a valid HTML.

Requirements
------------

[](#requirements)

- PHP 5.3.0 or later
- [Tidy](http://php.net/manual/en/intro.tidy.php) extension for PHP

Installation
------------

[](#installation)

Add Htmldiff to your `composer.json` file:

```
"require": {
    "gathercontent/htmldiff": "0.2.*"
}
```

Get composer to install the package:

```
$ composer update gathercontent/htmldiff
```

Usage
-----

[](#usage)

The input is going to be parsed by Tidy before diffing. Here's a few examples:

```
$old = 'This is a string';
$new = 'This is a text';

$htmldiff = new Htmldiff;
$result = $htmldiff->diff($old, $new);

// result: This is a stringtext
```

```
$old = 'Hello world, how do you do';
$new = 'Hello world, how do you do';

$htmldiff = new Htmldiff;
$result = $htmldiff->diff($old, $new);

// result: Hello world, how do youyou do
```

```
$old = 'Hello worldHow do you do';
$new = 'Hello worldfirst pointsecond pointHow do you do';

$htmldiff = new Htmldiff;
$result = $htmldiff->diff($old, $new);

// result: Hello worldfirst pointsecond pointHow do you do
```

Testing
-------

[](#testing)

Run unit tests:

```
$ ./vendor/bin/phpunit
```

Test compliance with [PSR2 coding style guide](http://www.php-fig.org/psr/psr-2/):

```
$ ./vendor/bin/phpcs --standard=PSR2 ./src
```

Licence
=======

[](#licence)

The MIT License (MIT) - see `README.md`

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity41

Moderate usage in the ecosystem

Community15

Small or concentrated contributor base

Maturity55

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 ~177 days

Total

3

Last Release

4051d ago

### Community

Maintainers

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

---

Top Contributors

[![acairns](https://avatars.githubusercontent.com/u/705212?v=4)](https://github.com/acairns "acairns (22 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/gathercontent-htmldiff/health.svg)

```
[![Health](https://phpackages.com/badges/gathercontent-htmldiff/health.svg)](https://phpackages.com/packages/gathercontent-htmldiff)
```

PHPackages © 2026

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