PHPackages                             hirasso/html-processor - 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. hirasso/html-processor

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

hirasso/html-processor
======================

A tiny HTML processor written in PHP 🐘

v2.1.3(1mo ago)080[1 PRs](https://github.com/hirasso/html-processor/pulls)MITPHPPHP &gt;=8.4

Since Jan 9Pushed 1mo agoCompare

[ Source](https://github.com/hirasso/html-processor)[ Packagist](https://packagist.org/packages/hirasso/html-processor)[ GitHub Sponsors](https://github.com/hirasso)[ RSS](/packages/hirasso-html-processor/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (15)Versions (41)Used By (0)

Note

This package is abandoned in favor of two new packages: [hirasso/prose](https://github.com/hirasso/prose/) and [hirasso/html-obfuscator](https://github.com/hirasso/html-obfuscator).

hirasso/html-processor
======================

[](#hirassohtml-processor)

**A tiny HTML processor written in PHP 🐘**

Features (all optional)
-----------------------

[](#features-all-optional)

- Automatically convert raw URLs to links
- Remove empty elements
- Process anchor `a` elements:
    - Add classes reflecting the link type (e.g. `link--external link--file`)
    - Open external links in a new tab
- Obfuscate email addresses and phone numbers to confuse spam bots (see [this article](https://spencermortensen.com/articles/email-obfuscation/))
- Automatically link prefixed words (e.g. `@mention` or `#hashtag`) to a URL of your choice
- Apply arbitrary DOM mutations with full access to the `HTMLDocument`
- Strip tags
- Conditionally apply any operation

Promises
--------

[](#promises)

- Fluent API
- Fully compatible with HTML5
- All mutations are lazily queued and processed in one go
- Extensively tested

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

[](#installation)

```
composer require hirasso/html-processor
```

Minimal Example
---------------

[](#minimal-example)

```
use function Hirasso\HTMLProcessor\process;

/** remove empty parahraphs from HTML */
echo process($html)->removeEmptyElements('p');
```

Maximal Example
---------------

[](#maximal-example)

```
use function Hirasso\HTMLProcessor\process;

echo process($html)
    ->autolinkUrls()
    ->removeEmptyElements('p')
    ->processLinks(fn ($link) => $link->addClasses()->openExternalInNewTab())
    ->autolinkPrefix('@', 'https://your-instance.social/@')
    ->autolinkPrefix('#', 'https://your-instance.social/tags')
    /** ->mutate() gives you direct access to the HTMLDocument: */
    ->mutate(fn (\Dom\HTMLDocument $doc) => $doc->querySelector('h1')?->setAttribute('class', 'text-2xl'))
    /** ->when() accepts a bool or a closure as the condition: */
    ->when($isRichText, fn ($p) => $p->stripTags(allowedTags: ['p', 'a', 'strong', 'em']));
```

→ Browse the [tests folder](./tests/) for more usage examples.

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance90

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 90.7% 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 ~4 days

Total

36

Last Release

58d ago

Major Versions

v0.7.1 → v1.0.02026-06-16

v1.0.0 → v2.0.02026-06-17

PHP version history (3 changes)v0.0.1PHP &gt;=8.1

v0.6.3PHP &gt;=8.2

v1.0.0PHP &gt;=8.4

### Community

Maintainers

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

---

Top Contributors

[![hirasso](https://avatars.githubusercontent.com/u/869813?v=4)](https://github.com/hirasso "hirasso (353 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (36 commits)")

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/hirasso-html-processor/health.svg)

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

###  Alternatives

[laravel/framework

The Laravel Framework.

34.9k556.2M21.5k](/packages/laravel-framework)[craftcms/cms

Craft CMS

3.6k3.7M3.4k](/packages/craftcms-cms)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

762297.9k53](/packages/civicrm-civicrm-core)[tempest/framework

The PHP framework that gets out of your way.

2.3k37.6k21](/packages/tempest-framework)[cognesy/instructor-php

The complete AI toolkit for PHP: unified LLM API, structured outputs, agents, and coding agent control

326127.9k1](/packages/cognesy-instructor-php)[php-soap/wsdl

Deals with WSDLs

184.1M19](/packages/php-soap-wsdl)

PHPackages © 2026

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