PHPackages                             voku/html2text - 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. [Mail &amp; Notifications](/categories/mail)
4. /
5. voku/html2text

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

voku/html2text
==============

Only a Fork of -&gt; html2text: Converts HTML to formatted plain text

5.0.5(2mo ago)38342.7k↓50.3%8[1 PRs](https://github.com/voku/html2text/pulls)2GPL-2.0-or-laterPHPPHP &gt;=7.1.0CI passing

Since Oct 10Pushed 1w ago6 watchersCompare

[ Source](https://github.com/voku/html2text)[ Packagist](https://packagist.org/packages/voku/html2text)[ RSS](/packages/voku-html2text/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (4)Versions (67)Used By (2)

[![CI](https://github.com/voku/html2text/actions/workflows/ci.yml/badge.svg)](https://github.com/voku/html2text/actions/workflows/ci.yml)[![Coverage Status](https://camo.githubusercontent.com/6682c19179029abcb9755924e58e218f3df6d860d245ac525b22d57119eec438/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f766f6b752f68746d6c32746578742f62616467652e737667)](https://coveralls.io/r/voku/html2text)[![Codacy Badge](https://camo.githubusercontent.com/232e426ae43e33d6761ed7de57e12338b3aa3ec53c7c44c19f2f92512c0e3244/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f6439303330363635646531383461333039373937623332653033366132663737)](https://www.codacy.com/app/voku/html2text)[![Latest Stable Version](https://camo.githubusercontent.com/f59c5fa572b8f30d3a1699db0d9fa9b13b27e567bcbf5be65afdba22953f83b7/68747470733a2f2f706f7365722e707567782e6f72672f766f6b752f68746d6c32746578742f762f737461626c65)](https://packagist.org/packages/voku/html2text)[![Total Downloads](https://camo.githubusercontent.com/5ac45fe98b6e0c1f4547ac5f5cc9459a6ae9a822f28e3b2d35f940f80e4740b2/68747470733a2f2f706f7365722e707567782e6f72672f766f6b752f68746d6c32746578742f646f776e6c6f616473)](https://packagist.org/packages/voku/html2text)[![License](https://camo.githubusercontent.com/214a6843ebe82faaa19873d8e15fc15d6ac19c66bb390c67d8963d57b8289fe6/68747470733a2f2f706f7365722e707567782e6f72672f766f6b752f68746d6c32746578742f6c6963656e7365)](https://packagist.org/packages/voku/html2text)[![Donate to this project using Paypal](https://camo.githubusercontent.com/0d6e4d8b50b5983a58205941b1a581b1305903393b7a39da574e3f60af3c7f5b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f70617970616c2d646f6e6174652d79656c6c6f772e737667)](https://www.paypal.me/moelleken)[![Donate to this project using Patreon](https://camo.githubusercontent.com/f9e075baad95563481d35174d43ef50757281abb6bc795d0f473fad452afa030/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f70617472656f6e2d646f6e6174652d79656c6c6f772e737667)](https://www.patreon.com/voku)

📝 Html2Text
===========

[](#memo-html2text)

### Description

[](#description)

Convert HTML to formatted plain text, e.g. for text mails.

### Installation

[](#installation)

The recommended installation way is through [Composer](https://getcomposer.org).

```
$ composer require voku/html2text
```

### Basic Usage

[](#basic-usage)

```
$html = new \voku\Html2Text\Html2Text('Hello, &quot;world&quot;');

echo $html->getText();  // Hello, "WORLD"
```

### Extended Usage

[](#extended-usage)

Each element (h1, li, div, etc) can have the following options:

- 'case' =&gt; convert case (`Html2Text::OPTION_NONE, Html2Text::OPTION_UPPERCASE, Html2Text::OPTION_LOWERCASE , Html2Text::OPTION_UCFIRST, Html2Text::OPTION_TITLE`)
- 'prepend' =&gt; prepend a string
- 'append' =&gt; append a string

For example:

```
$html = 'Should have "AAA" changed to BBB• Custom bullet should be removed';
$expected = 'SHOULD HAVE "BBB" CHANGED TO BBB' . "\n\n" . '- Custom bullet should be removed |' . "\n\n" . '[IMAGE]: "The Linux Tux"';

$html2text = new Html2Text(
    $html,
    array(
        'width'    => 0,
        'elements' => array(
            'h1' => array(
              'case' => Html2Text::OPTION_UPPERCASE,
              'replace' => array('AAA', 'BBB')),
            'li' => array(
              'case' => Html2Text::OPTION_NONE,
              'replace' => array('•', ''),
              'prepend' => "- ",
              'append' => " |",
            ),
        ),
    )
);

$html2text->setPrefixForImages('[IMAGE]: ');
$html2text->setPrefixForLinks('[LINKS]: ');
$html2text->getText(); // === $expected
```

### Live Demo

[](#live-demo)

- [HTML](https://suckup.de/2016/01/was-habe-ich-als-fachinformatiker-bisher-gelernt/) | [TEXT](https://moelleken.org/url_to_text.php?url=https://suckup.de/2016/01/was-habe-ich-als-fachinformatiker-bisher-gelernt/)
- [https://moelleken.org/url\_to\_text.php?url=https://ADD\_YOUR\_URL\_HERE](https://moelleken.org/url_to_text.php?url=https://ADD_YOUR_URL_HERE)

### History

[](#history)

This library started life on the blog of Jon Abernathy

A number of projects picked up the library and started using it - among those was RoundCube mail. They made a number of updates to it over time to suit their webmail client.

Now this is a extend fork of the original [Html2Text](https://github.com/mtibben/html2text).

### Support

[](#support)

For support and donations please visit [Github](https://github.com/voku/portable-utf8/) | [Issues](https://github.com/voku/portable-utf8/issues) | [PayPal](https://paypal.me/moelleken) | [Patreon](https://www.patreon.com/voku).

For status updates and release announcements please visit [Releases](https://github.com/voku/portable-utf8/releases) | [Twitter](https://twitter.com/suckup_de) | [Patreon](https://www.patreon.com/voku/posts).

For professional support please contact [me](https://about.me/voku).

### Thanks

[](#thanks)

- Thanks to [GitHub](https://github.com) (Microsoft) for hosting the code and a good infrastructure including Issues-Managment, etc.
- Thanks to [IntelliJ](https://www.jetbrains.com) as they make the best IDEs for PHP and they gave me an open source license for PhpStorm!
- Thanks to [GitHub Actions](https://github.com/features/actions) for the automated CI pipeline.
- Thanks to [StyleCI](https://styleci.io/) for the simple but powerful code style check.
- Thanks to [PHPStan](https://github.com/phpstan/phpstan) &amp;&amp; [Psalm](https://github.com/vimeo/psalm) for really great Static analysis tools and for discover bugs in the code!

###  Health Score

63

—

FairBetter than 99% of packages

Maintenance93

Actively maintained with recent releases

Popularity46

Moderate usage in the ecosystem

Community27

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 50.2% 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 ~90 days

Recently: every ~686 days

Total

51

Last Release

70d ago

Major Versions

1.0.1 → 2.0.02014-10-18

2.0.1 → 3.0.02015-07-16

3.4.12 → 4.0.02017-11-19

4.0.0 → 5.0.02017-12-23

PHP version history (3 changes)3.0.0PHP &gt;=5.3.0

4.0.0PHP &gt;=7.0.0

5.0.5PHP &gt;=7.1.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/6456fe693db197c458272cb758bf78958bc7d3e787ccd59db4bf3cf41654316a?d=identicon)[voku](/maintainers/voku)

---

Top Contributors

[![voku](https://avatars.githubusercontent.com/u/264695?v=4)](https://github.com/voku "voku (104 commits)")[![mtibben](https://avatars.githubusercontent.com/u/980499?v=4)](https://github.com/mtibben "mtibben (57 commits)")[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (20 commits)")[![pwillcode](https://avatars.githubusercontent.com/u/6126513?v=4)](https://github.com/pwillcode "pwillcode (7 commits)")[![andrewnicols](https://avatars.githubusercontent.com/u/370047?v=4)](https://github.com/andrewnicols "andrewnicols (6 commits)")[![ianhk](https://avatars.githubusercontent.com/u/3003415?v=4)](https://github.com/ianhk "ianhk (1 commits)")[![mario-kinesissurvey-com](https://avatars.githubusercontent.com/u/8127237?v=4)](https://github.com/mario-kinesissurvey-com "mario-kinesissurvey-com (1 commits)")[![Nyholm](https://avatars.githubusercontent.com/u/1275206?v=4)](https://github.com/Nyholm "Nyholm (1 commits)")[![pstast](https://avatars.githubusercontent.com/u/5357442?v=4)](https://github.com/pstast "pstast (1 commits)")[![scaytrase](https://avatars.githubusercontent.com/u/6578413?v=4)](https://github.com/scaytrase "scaytrase (1 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (1 commits)")[![Synchro](https://avatars.githubusercontent.com/u/81561?v=4)](https://github.com/Synchro "Synchro (1 commits)")[![wolfwolker](https://avatars.githubusercontent.com/u/1926137?v=4)](https://github.com/wolfwolker "wolfwolker (1 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (1 commits)")[![dsas](https://avatars.githubusercontent.com/u/93301?v=4)](https://github.com/dsas "dsas (1 commits)")[![dvdoug](https://avatars.githubusercontent.com/u/1571110?v=4)](https://github.com/dvdoug "dvdoug (1 commits)")

---

Tags

hacktoberfesthtml2textmailphpemailhtmltextHTMLToTexthtml-to-textHtmlIntoText

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/voku-html2text/health.svg)

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

###  Alternatives

[soundasleep/html2text

A PHP script to convert HTML into a plain text format

48021.2M91](/packages/soundasleep-html2text)[snowfire/beautymail

Send beautiful html emails with Laravel

1.3k752.6k2](/packages/snowfire-beautymail)[osiemsiedem/laravel-autolink

A Laravel package for converting URLs in a given string of text into clickable links.

12139.9k](/packages/osiemsiedem-laravel-autolink)

PHPackages © 2026

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