PHPackages                             docxpresso/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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. docxpresso/html2text

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

docxpresso/html2text
====================

A simple package that converts HTML into plain text using DOM methods

v1.2(9y ago)56.6k1MITPHPPHP &gt;=5.4

Since May 3Pushed 9y agoCompare

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

READMEChangelogDependencies (1)Versions (4)Used By (0)

HTML to Plain Text Converter
============================

[](#html-to-plain-text-converter)

HTML2TEXT is a single class PHP package that converts HTML into plain text.

It uses DOM methods rather than regular expressions and although it works out of the box it can be easily further customized to suit any particular need.

You can visit the official page in [Docxpresso](http://www.docxpresso.com/documentation-api/html2text).

Installing HTML2TEXT
--------------------

[](#installing-html2text)

The recommended way to install HTML2TEXT is through [Composer](http://getcomposer.org).

```
# Install Composer
curl -sS https://getcomposer.org/installer | php
```

Next, run the Composer command to install the latest stable version of HTML2TEXT:

```
php composer.phar require docxpresso/html2text
```

After installing, you need to require Composer's autoloader:

```
require 'vendor/autoload.php';
```

You can then later update HTML2TEXT using composer:

```
composer.phar update
```

Using HTML2TEXT
---------------

[](#using-html2text)

The use of HTML2TEXT is extremely simple:

```
require __DIR__ . '/../vendor/autoload.php';
use Docxpresso\HTML2TEXT as Parser;
$html = 'A simple paragraph.';
$parser = new Parser\HTML2TEXT($html);
echo $parser->plainText();
```

You can override some of the default values by including an **options** array whenever you invoke the HTML2TEXT class. The following options are available:

- **bold**: a string of chars that will wrap text in **b** or **strong** tags. The default value is an empty string.
- **cellSeparator**: a string of chars used to separate content between contiguous cells in a row. Default value is " || " (\\t may be also a sensible choice)
- **images**: if set to true the alt value associated to the image will be printed like \[img: alt value\]. Default value is true.
- **italics**: a string of chars that will wrap text in **i** or **em** tags. The default value is an empty string.
- **newLine**: if set it will replace the default value (\\n\\r) for titles and paragraphs.
- **tab**: a string of chars that will be used like a "tab". The default value is " " (\\t may be another standard option)
- **titles**: it can be "underline" (default), "uppercase" or "none".

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~6 days

Total

3

Last Release

3333d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/901b363f4ab908d8f4c6b88b1ecef2bf02218a165557610bb41935ffc96598df?d=identicon)[Docxpresso](/maintainers/Docxpresso)

---

Top Contributors

[![Docxpresso](https://avatars.githubusercontent.com/u/24776724?v=4)](https://github.com/Docxpresso "Docxpresso (18 commits)")

---

Tags

htmldomtexttxt

### Embed Badge

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

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

###  Alternatives

[masterminds/html5

An HTML5 parser and serializer.

1.8k260.4M295](/packages/masterminds-html5)[paquettg/php-html-parser

An HTML DOM parser. It allows you to manipulate HTML. Find tags on an HTML page with selectors just like jQuery.

2.4k8.1M127](/packages/paquettg-php-html-parser)[sunra/php-simple-html-dom-parser

Composer adaptation of: A HTML DOM parser written in PHP5+ let you manipulate HTML in a very easy way! Require PHP 5+. Supports invalid HTML. Find tags on an HTML page with selectors just like jQuery. Extract contents from HTML in a single line.

1.3k9.6M64](/packages/sunra-php-simple-html-dom-parser)[sabre/xml

sabre/xml is an XML library that you may not hate.

52933.7M139](/packages/sabre-xml)[scotteh/php-dom-wrapper

Simple DOM wrapper to select nodes using either CSS or XPath expressions and manipulate results quickly and easily.

1482.0M11](/packages/scotteh-php-dom-wrapper)[kub-at/php-simple-html-dom-parser

PHP Simple HTML DOM Parser with namespace and PHP 7.3 compatible

1526.7M35](/packages/kub-at-php-simple-html-dom-parser)

PHPackages © 2026

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