PHPackages                             noone-silent/rtf-html-php - 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. noone-silent/rtf-html-php

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

noone-silent/rtf-html-php
=========================

RTF to HTML converter in PHP

v1.3.3(9mo ago)01.7k↓68.8%MITPHPPHP ^8.0

Since Sep 16Pushed 9mo agoCompare

[ Source](https://github.com/noone-silent/rtf-html-php)[ Packagist](https://packagist.org/packages/noone-silent/rtf-html-php)[ RSS](/packages/noone-silent-rtf-html-php/feed)WikiDiscussions master Synced yesterday

READMEChangelog (4)Dependencies (1)Versions (5)Used By (0)

rtf-html-php
============

[](#rtf-html-php)

*An RTF to HTML converter in PHP*

In a recent project, I desperately needed an RTF to HTML converter written in PHP. Googling around turned up some matches, but I could not get them to work properly. Also, one of them called `passthru()` to use a RTF2HTML executable, which is something I didn’t want. I was looking for an RTF to HTML converter written purely in PHP.

Since I couldn’t find anything ready-made, I sat down and coded one up myself. It’s short, and it works, implementing the subset of RTF tags that you’ll need in HTML and ignoring the rest. As it turns out, the RTF format isn’t that complicated when you really look at it, but it isn’t something you code a parser for in 15 minutes either.

How to use it
-------------

[](#how-to-use-it)

Install this package using composer. Then do this:

```
use RtfHtmlPhp\Document;

$rtf = file_get_contents("test.rtf");
$document = new Document($rtf); // or use a string directly
```

`Document` will raise an exception if the RTF document could not be parsed. Parse errors will generate PHP notices.

If you’d like to see what the parser read (for debug purposes), then call this:

```
echo $document;
```

To convert the parser’s parse tree to HTML, call this (but only if the RTF was successfully parsed):

```
use RtfHtmlPhp\Html\HtmlFormatter;
$formatter = new HtmlFormatter();
echo $formatter->Format($document);
```

For enhanced compatibility the default character encoding of the converted RTF unicode characters is set to `HTML-ENTITIES`. To change the default encoding, you can initialize the `Html` object with the desired encoding supported by `mb_list_encodings()`: ex. `UTF-8`

```
$formatter = new HtmlFormatter('UTF-8');
```

Install via Composer
--------------------

[](#install-via-composer)

```
composer require henck/rtf-to-html
```

Caveats
-------

[](#caveats)

- Please note that rtf-html-php requires your PHP installation to support the `mb_convert_encoding` function. Therefore you must have the `php-mbstring` module installed. For fresh PHP installations, it will usually be there.

License
-------

[](#license)

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance56

Moderate activity, may be stable

Popularity20

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~0 days

Total

4

Last Release

289d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1089817?v=4)[n\[oO\]ne](/maintainers/noone-silent)[@noone-silent](https://github.com/noone-silent)

---

Top Contributors

[![henck](https://avatars.githubusercontent.com/u/10880501?v=4)](https://github.com/henck "henck (67 commits)")[![sipryan](https://avatars.githubusercontent.com/u/32551786?v=4)](https://github.com/sipryan "sipryan (43 commits)")[![rafaelapuka](https://avatars.githubusercontent.com/u/21339687?v=4)](https://github.com/rafaelapuka "rafaelapuka (9 commits)")[![hc0503](https://avatars.githubusercontent.com/u/54434088?v=4)](https://github.com/hc0503 "hc0503 (3 commits)")[![bnd170](https://avatars.githubusercontent.com/u/5690663?v=4)](https://github.com/bnd170 "bnd170 (2 commits)")[![cyrosy](https://avatars.githubusercontent.com/u/2836107?v=4)](https://github.com/cyrosy "cyrosy (2 commits)")[![harlong](https://avatars.githubusercontent.com/u/116577111?v=4)](https://github.com/harlong "harlong (2 commits)")[![zonuexe](https://avatars.githubusercontent.com/u/822086?v=4)](https://github.com/zonuexe "zonuexe (2 commits)")[![elvis-epx](https://avatars.githubusercontent.com/u/5000832?v=4)](https://github.com/elvis-epx "elvis-epx (1 commits)")[![JuliusPC](https://avatars.githubusercontent.com/u/15018932?v=4)](https://github.com/JuliusPC "JuliusPC (1 commits)")[![lbm-services](https://avatars.githubusercontent.com/u/5830407?v=4)](https://github.com/lbm-services "lbm-services (1 commits)")[![Leshana](https://avatars.githubusercontent.com/u/14110581?v=4)](https://github.com/Leshana "Leshana (1 commits)")[![livkiss](https://avatars.githubusercontent.com/u/256075?v=4)](https://github.com/livkiss "livkiss (1 commits)")[![lm-cmxkonzepte](https://avatars.githubusercontent.com/u/45796141?v=4)](https://github.com/lm-cmxkonzepte "lm-cmxkonzepte (1 commits)")[![datashaman](https://avatars.githubusercontent.com/u/59514?v=4)](https://github.com/datashaman "datashaman (1 commits)")[![RsAalund](https://avatars.githubusercontent.com/u/71169600?v=4)](https://github.com/RsAalund "RsAalund (1 commits)")[![bretto36](https://avatars.githubusercontent.com/u/6217994?v=4)](https://github.com/bretto36 "bretto36 (1 commits)")[![vmrfriz](https://avatars.githubusercontent.com/u/25864985?v=4)](https://github.com/vmrfriz "vmrfriz (1 commits)")[![Fosnez](https://avatars.githubusercontent.com/u/8691414?v=4)](https://github.com/Fosnez "Fosnez (1 commits)")

---

Tags

converterrtf

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/noone-silent-rtf-html-php/health.svg)

```
[![Health](https://phpackages.com/badges/noone-silent-rtf-html-php/health.svg)](https://phpackages.com/packages/noone-silent-rtf-html-php)
```

###  Alternatives

[mark-gerarts/auto-mapper-plus

An AutoMapper for PHP

5623.5M23](/packages/mark-gerarts-auto-mapper-plus)[iamcal/php-emoji

This is a PHP library for dealing with Emoji, allowing you to convert between various native formats and displaying them using HTML.

1.3k550.9k](/packages/iamcal-php-emoji)[henck/rtf-to-html

RTF to HTML converter in PHP

108868.1k1](/packages/henck-rtf-to-html)[matthiasmullie/path-converter

Relative path converter

10632.1M9](/packages/matthiasmullie-path-converter)[ncjoes/office-converter

PHP Wrapper for LibreOffice

2501.4M4](/packages/ncjoes-office-converter)[magyarandras/amp-converter

A library to convert HTML articles, blog posts or similar content to AMP (Accelerated Mobile Pages).

65155.7k](/packages/magyarandras-amp-converter)

PHPackages © 2026

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