PHPackages                             groovenectar/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. groovenectar/html2text

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

groovenectar/html2text
======================

A PHP script to convert HTML into a plain text format

1.1.2(3y ago)0115MITHTMLPHP ^7.3|^8.0

Since May 16Pushed 3y ago1 watchersCompare

[ Source](https://github.com/groovenectar/html2text)[ Packagist](https://packagist.org/packages/groovenectar/html2text)[ Docs](https://github.com/soundasleep/html2text)[ RSS](/packages/groovenectar-html2text/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (2)Dependencies (2)Versions (17)Used By (0)

[![example workflow](https://github.com/soundasleep/html2text/actions/workflows/test.yml/badge.svg)](https://github.com/soundasleep/html2text/actions/workflows/test.yml/badge.svg) [![Total Downloads](https://camo.githubusercontent.com/9e4a7d4a0a88d868d5ec5b11b5a29d2b5bb620adc808bdcfb242347954b886d2/68747470733a2f2f706f7365722e707567782e6f72672f736f756e6461736c6565702f68746d6c32746578742f646f776e6c6f6164732e706e67)](https://packagist.org/packages/soundasleep/html2text)
========================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#-)

html2text is a very simple script that uses DOM methods to convert HTML into a format similar to what would be rendered by a browser - perfect for places where you need a quick text representation. For example:

```

Ignored Title

  Hello, World!

  This is some e-mail content.
  Even though it has whitespace and newlines, the e-mail converter
  will handle it correctly.

  Even mismatched tags.

  A div
  Another div
  A divwithin a div

  A link

```

Will be converted into:

```
Hello, World!

This is some e-mail content. Even though it has whitespace and newlines, the e-mail converter will handle it correctly.

Even mismatched tags.

A div
Another div
A div
within a div

[A link](http://foo.com)

```

See the [original blog post](http://journals.jevon.org/users/jevon-phd/entry/19818) or the related [StackOverflow answer](http://stackoverflow.com/a/2564472/39531).

Installing
----------

[](#installing)

You can use [Composer](http://getcomposer.org/) to add the [package](https://packagist.org/packages/soundasleep/html2text) to your project:

```
{
  "require": {
    "soundasleep/html2text": "~1.1"
  }
}
```

And then use it quite simply:

```
$text = \Soundasleep\Html2Text::convert($html);
```

You can also include the supplied `html2text.php` and use `$text = convert_html_to_text($html);` instead.

### Options

[](#options)

OptionDefaultDescription**ignore\_errors**`false`Set to `true` to ignore any XML parsing errors.**drop\_links**`false`Set to `true` to not render links as `[http://foo.com](My Link)`, but rather just `My Link`.**char\_set**`'auto'`Specify a specific character set. Pass multiple character sets (comma separated) to detect encoding, default is ASCII,UTF-8Pass along options as a second argument to `convert`, for example:

```
$options = array(
  'ignore_errors' => true,
  // other options go here
);
$text = \Soundasleep\Html2Text::convert($html, $options);
```

Tests
-----

[](#tests)

Some very basic tests are provided in the `tests/` directory. Run them with `composer install && vendor/bin/phpunit`.

Troubleshooting
---------------

[](#troubleshooting)

### Class 'DOMDocument' not found

[](#class-domdocument-not-found)

You need to [install the PHP XML extension](https://github.com/soundasleep/html2text/issues/55) for your PHP version. e.g. `apt-get install php7.4-xml`

License
-------

[](#license)

`html2text` is [licensed under MIT](LICENSE.md), making it suitable for both Eclipse and GPL projects.

Other versions
--------------

[](#other-versions)

Also see [html2text\_ruby](https://github.com/soundasleep/html2text_ruby), a Ruby implementation.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 66.4% 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 ~218 days

Recently: every ~551 days

Total

16

Last Release

1109d ago

Major Versions

0.5.0 → 1.0.02019-02-14

PHP version history (3 changes)0.1.0PHP &gt;=5.3.2

1.0.0PHP &gt;=7.0

1.1.1PHP ^7.3|^8.0

### Community

Maintainers

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

---

Top Contributors

[![soundasleep](https://avatars.githubusercontent.com/u/3889656?v=4)](https://github.com/soundasleep "soundasleep (85 commits)")[![phpfui](https://avatars.githubusercontent.com/u/7434059?v=4)](https://github.com/phpfui "phpfui (14 commits)")[![edgrosvenor](https://avatars.githubusercontent.com/u/1053395?v=4)](https://github.com/edgrosvenor "edgrosvenor (7 commits)")[![groovenectar](https://avatars.githubusercontent.com/u/595446?v=4)](https://github.com/groovenectar "groovenectar (6 commits)")[![vanhoavn](https://avatars.githubusercontent.com/u/3288188?v=4)](https://github.com/vanhoavn "vanhoavn (2 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (2 commits)")[![manzoorwanijk](https://avatars.githubusercontent.com/u/18226415?v=4)](https://github.com/manzoorwanijk "manzoorwanijk (1 commits)")[![maskas](https://avatars.githubusercontent.com/u/1159983?v=4)](https://github.com/maskas "maskas (1 commits)")[![pethersonmorenosqg](https://avatars.githubusercontent.com/u/9138772?v=4)](https://github.com/pethersonmorenosqg "pethersonmorenosqg (1 commits)")[![jaylinski](https://avatars.githubusercontent.com/u/1668766?v=4)](https://github.com/jaylinski "jaylinski (1 commits)")[![SDKiller](https://avatars.githubusercontent.com/u/2150916?v=4)](https://github.com/SDKiller "SDKiller (1 commits)")[![guillaume-ro-fr](https://avatars.githubusercontent.com/u/1820051?v=4)](https://github.com/guillaume-ro-fr "guillaume-ro-fr (1 commits)")[![Stadly](https://avatars.githubusercontent.com/u/7263579?v=4)](https://github.com/Stadly "Stadly (1 commits)")[![thetaylor82](https://avatars.githubusercontent.com/u/2462662?v=4)](https://github.com/thetaylor82 "thetaylor82 (1 commits)")[![timothyasp](https://avatars.githubusercontent.com/u/707699?v=4)](https://github.com/timothyasp "timothyasp (1 commits)")[![tommygnr](https://avatars.githubusercontent.com/u/929392?v=4)](https://github.com/tommygnr "tommygnr (1 commits)")[![ulrichsg](https://avatars.githubusercontent.com/u/197901?v=4)](https://github.com/ulrichsg "ulrichsg (1 commits)")[![cyrosy](https://avatars.githubusercontent.com/u/2836107?v=4)](https://github.com/cyrosy "cyrosy (1 commits)")

---

Tags

phpemailhtmltext

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[soundasleep/html2text

A PHP script to convert HTML into a plain text format

48419.5M75](/packages/soundasleep-html2text)[voku/html2text

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

39335.8k2](/packages/voku-html2text)[henrique-borba/php-sieve-manager

A modern (started in 2022) PHP library for the ManageSieve protocol (RFC5804) to create/edit Sieve scripts (RFC5228). Used by Cypht Webmail.

23125.7k2](/packages/henrique-borba-php-sieve-manager)

PHPackages © 2026

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