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

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

masroore/html2text
==================

A PHP package to convert HTML into a plain text format

0.0.1(3y ago)111.2k↓35.3%MITPHPPHP ^8.0 || ^8.1

Since Jun 13Pushed 3y ago1 watchersCompare

[ Source](https://github.com/masroore/php-html2text)[ Packagist](https://packagist.org/packages/masroore/html2text)[ Docs](https://github.com/masroore/php-html2text)[ RSS](/packages/masroore-html2text/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (10)Versions (2)Used By (0)

A PHP package to convert HTML into plain text -- no HTML tags allowed in the output.
====================================================================================

[](#a-php-package-to-convert-html-into-plain-text----no-html-tags-allowed-in-the-output)

[![Latest Version on Packagist](https://camo.githubusercontent.com/c0bbf0302b60b129fccd50819fef81c0e35dd15171518d81fe77bb4819d96cd9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6173726f6f72652f68746d6c32746578742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/masroore/html2text)[![GitHub Tests Action Status](https://camo.githubusercontent.com/0244c95cd32c610553e49252a7229d6a6f0926975c3f8631047d18c8d6db0ac7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6d6173726f6f72652f7068702d68746d6c32746578742f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/masroore/php-html2text/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/5b650264033b028b57c4ebd1780e64bf5c3d454bef044c91eff413f3bccf80a7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6d6173726f6f72652f7068702d68746d6c32746578742f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65)](https://github.com/masroore/php-html2text/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/1941d3e409af9d9b15fc9c4e48b6271d1a98c119eb9650336e75eaf8d4cc7394/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6173726f6f72652f68746d6c32746578742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/masroore/html2text)

Overview
--------

[](#overview)

**masroore/html2text** is a PHP package that converts a page of HTML into clean, easy-to-read plain ASCII text.

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

[](#installation)

> **Requires [PHP 8.0+](https://php.net/releases/)**

You can install the package via composer:

```
composer require masroore/html2text
```

Usage
-----

[](#usage)

Extract text from HTML:

```
use Kaiju\Html2Text\Html2Text;

$converter = new Html2Text();
echo $converter->convert($html);
```

**Callback functions**

You are able to change process of formatting by providing callbacks in pre-processing, tag-replacing and post-processing:

```
# assign a pre-processing callback function. (transform href links)
$converter->setPreProcessingCallback(fn (string $s) => preg_replace('%]*href=[\'"](.*?)[\'"][^>]*>([\s\S]*?)%i', '$2 ($1)', $s));

# assign a tag-replacement callback function. (replace  tags)
$converter->setTagReplacementCallback(fn (string $s) => preg_replace('/]*>/i', "\n- ", $s));

# post-processing hook
$converter->setPostProcessingCallback(...);

# process HTML
echo $converter->convert($html);
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Thank you for considering to contribute to Html2Text. All the contribution guidelines are mentioned [here](CONTRIBUTING.md).

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Masroor Ehsan](https://github.com/masroore)
- [All Contributors](../../contributors)

License
-------

[](#license)

Html2Text is an open-sourced software licensed under the [MIT license](LICENSE.md).

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1436d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/200963?v=4)[Masroor Ehsan](/maintainers/masroore)[@masroore](https://github.com/masroore)

---

Top Contributors

[![masroore](https://avatars.githubusercontent.com/u/200963?v=4)](https://github.com/masroore "masroore (5 commits)")

---

Tags

htmlhtml-parserhtml2texthtmltexthtml2text

###  Code Quality

TestsPest

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[league/html-to-markdown

An HTML-to-markdown conversion helper for PHP

1.9k28.6M199](/packages/league-html-to-markdown)[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.4k7.9M123](/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.4M61](/packages/sunra-php-simple-html-dom-parser)[texy/texy

Texy converts plain text in easy to read Texy syntax into structurally valid (X)HTML. It supports adding of images, links, nested lists, tables and has full support for CSS. Texy supports hyphenation of long words (which reflects language rules), clickable emails and URL (emails are obfuscated against spambots), national typographic single and double quotation marks, ellipses, em dashes, dimension sign, nonbreakable spaces (e.g. in phone numbers), acronyms, arrows and many others. Texy code can optionally contain HTML tags.

161838.9k15](/packages/texy-texy)[interaction-design-foundation/nova-html-card

A Laravel Nova card to display arbitrary HTML content

67731.2k3](/packages/interaction-design-foundation-nova-html-card)

PHPackages © 2026

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