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

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

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

A tiny HTML processor written in PHP 🐘

v0.7.1(3mo ago)069[1 issues](https://github.com/hirasso/html-processor/issues)MITPHPPHP &gt;=8.2CI passing

Since Jan 9Pushed 3mo 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 (9)Versions (33)Used By (0)

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

[](#hirassohtml-processor)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4cea7173f218eb85c9a2def2ff7f366d2feb1c6b0816139943f1b9d41c2818df/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6869726173736f2f68746d6c2d70726f636573736f722e7376673f636f6c6f723d336566303964)](https://packagist.org/packages/hirasso/html-processor)[![Test Status](https://camo.githubusercontent.com/a4f3bdd411b24928ef95b70a837c82ab4ee3390e9feb3d3ad221d263b56235f0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6869726173736f2f68746d6c2d70726f636573736f722f63692e796d6c3f6c6162656c3d746573747326636f6c6f723d336566303964)](https://github.com/hirasso/html-processor/actions/workflows/ci.yml)[![Code Coverage](https://camo.githubusercontent.com/6a00f264f1c00a73d57221e2c6133e09173bcd077905fb17ea976e59cb2f093d/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6869726173736f2f68746d6c2d70726f636573736f723f636f6c6f723d336566303964)](https://app.codecov.io/gh/hirasso/html-processor)

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

Warning

The API hasn't stabilized, yet. Use with caution, ideally in combination with a tool like [phpstan/phpstan](https://github.com/phpstan/phpstan)

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

[](#features-all-optional)

- Automatically convert raw URLs to links
- Remove empty elements
- Optimize typography:
    - Localize quotes (currently supported languages, `en`, `de`, `fr`)
    - Avoid short last lines (traditionally called "Widows")
- Process links:
    - Add link classes based on type (e.g. `link--external link--file link--ext--pdf`)
    - Open external links in new tab
- Encode email addresses to confuse spam bots
- Automatically link prefixed words (e.g. `@mention` or `#hashtag`) to a URL of your choice

Promises
--------

[](#promises)

- Fluent API
- Understands HTML5
- Optimized for performance
- Extensively tested

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

[](#installation)

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

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

[](#minimal-example)

```
use function Hirasso\HTMLProcessor\process;

echo process($html)->typography('de');
```

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

[](#maximal-example)

```
use function Hirasso\HTMLProcessor\process;

echo process($html)
    ->autolinkUrls()
    ->removeEmptyElements('p')
    ->encodeEmails()
    ->typography('de', fn ($typo) => $typo->localizeQuotes()->avoidShortLastLines())
    ->processLinks(fn ($link) => $link->addClasses()->openExternalInNewTab())
    ->autolinkPrefix('@', 'https://your-instance.social/@')
    ->autolinkPrefix('#', 'https://your-instance.social/tags');
```

- Browse the [tests/Feature folder](./tests/Feature) for more usage examples.
- See the [list of currently supported quote styles](./src/Service/DOM/QuoteLocalizer/QuoteStyle.php) here.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance79

Regular maintenance activity

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 89.8% 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 ~0 days

Total

28

Last Release

109d ago

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

v0.6.3PHP &gt;=8.2

### 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 (246 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (28 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

[league/uri-components

URI components manipulation library

31932.3M67](/packages/league-uri-components)[scssphp/scssphp

scssphp is a compiler for SCSS written in PHP.

62827.7M220](/packages/scssphp-scssphp)[fivefilters/readability.php

A PHP port of Readability.js

311826.8k5](/packages/fivefilters-readabilityphp)[php-soap/wsdl

Deals with WSDLs

173.5M12](/packages/php-soap-wsdl)[bezhansalleh/filament-panel-switch

Easily Switch between your Filament Panels

159323.5k2](/packages/bezhansalleh-filament-panel-switch)[jane-php/json-schema-runtime

Jane runtime Library

1811.1M13](/packages/jane-php-json-schema-runtime)

PHPackages © 2026

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