PHPackages                             sunra/html\_to\_text - 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. sunra/html\_to\_text

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

sunra/html\_to\_text
====================

Working horse HTML to text convertor for PHP. Years of finding right choice

52242PHP

Since Dec 13Pushed 10y ago2 watchersCompare

[ Source](https://github.com/sunra/HtmlToText)[ Packagist](https://packagist.org/packages/sunra/html_to_text)[ RSS](/packages/sunra-html-to-text/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (1)Used By (0)

HtmlToText
==========

[](#htmltotext)

Convert html to text, filter html tags, purify html. Best and most advanced html to text conversion library for php.

Used Htmlpurifier

Install
-------

[](#install)

Add

```
"ezyang/htmlpurifier": "dev-master",
"sunra/html_to_text": "dev-master"
```

to required section in you composer.json

Use
---

[](#use)

```
// Total remove tags. br converted to new lines
$plain_text = \Sunra\HtmlToText\HtmlToText::plain_text( $html );

// removed all tags but safest 'br,b,strong,li,ol,ul'
$safe_html = \Sunra\HtmlToText\HtmlToText::safe_html( $html );

// remove unsafe code (XSS attacks) and heals html - close tags etc
$purified_html = \Sunra\HtmlToText\HtmlToText::purify( $html );

// Remove all tags but allowed (coma separated - for example 'br,b')
$purified_html = \Sunra\HtmlToText\HtmlToText::filter( $html, $allowed_tags );
```

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/1b66ec3a106b163a290acec0bfcb2261fac0d31f7381ab8885905b699098b82c?d=identicon)[sunra](/maintainers/sunra)

---

Top Contributors

[![sunra](https://avatars.githubusercontent.com/u/635370?v=4)](https://github.com/sunra "sunra (14 commits)")

### Embed Badge

![Health badge](/badges/sunra-html-to-text/health.svg)

```
[![Health](https://phpackages.com/badges/sunra-html-to-text/health.svg)](https://phpackages.com/packages/sunra-html-to-text)
```

###  Alternatives

[neo/laravel-early-access

Adds an early access page to your Laravel application.

1781.1k](/packages/neo-laravel-early-access)[netresearch/contexts

Multi-channel content visibility for TYPO3 - by Netresearch

1119.0k1](/packages/netresearch-contexts)[honeybee/honeybee

Library for implementing CQRS driven, event-sourced and distributed architectures.

212.1k4](/packages/honeybee-honeybee)

PHPackages © 2026

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