PHPackages                             macropage/ansi-to-html - 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. macropage/ansi-to-html

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

macropage/ansi-to-html
======================

A library to convert a text with ANSI codes to HTML

v1.2.1(5y ago)06231MITPHPPHP &gt;=7.2.5

Since Mar 19Pushed 4y agoCompare

[ Source](https://github.com/michabbb/ansi-to-html)[ Packagist](https://packagist.org/packages/macropage/ansi-to-html)[ RSS](/packages/macropage-ansi-to-html/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (11)Used By (1)

this is fork of sensiolabs/ansi-to-html
=======================================

[](#this-is-fork-of-sensiolabsansi-to-html)

modified to by compatible with php 8.x

ANSI to HTML5 Converter
=======================

[](#ansi-to-html5-converter)

This small library only does one thing: converting a text containing ANSI codes to an HTML5 fragment:

```
require_once __DIR__.'/vendor/autoload.php';

use SensioLabs\AnsiConverter\AnsiToHtmlConverter;

$converter = new AnsiToHtmlConverter();

$html = $converter->convert($ansi);
```

The `$ansi` variable should contain a text with ANSI codes, and `$html` will contain the converted HTML5 version of it.

You can then output the HTML5 fragment in any HTML document:

```

        10px 15px; font-family: monospace;"
        >

```

The converter supports different color themes:

```
use SensioLabs\AnsiConverter\Theme\SolarizedTheme;

$theme = new SolarizedTheme();
$converter = new AnsiToHtmlConverter($theme);
```

By default, the colors are inlined into the HTML, but you can also use classes by turning off style inlining:

```
$converter = new AnsiToHtmlConverter($theme, false);
```

And the `asCss()` method of the theme object lets you retrieve the theme styles as a CSS snippet:

```
$styles = $theme->asCss();
```

which you can then use in your HTML document:

```

            .ansi_box { overflow: auto; padding: 10px 15px; font-family: monospace; }

```

Twig Integration
----------------

[](#twig-integration)

Register the extension:

```
use SensioLabs\AnsiConverter\Bridge\Twig\AnsiExtension;

$twig->addExtension(AnsiExtension());
```

It's possible to use a custom `AnsiToHtmlConverter`:

```
use SensioLabs\AnsiConverter\Bridge\Twig\AnsiExtension;
use SensioLabs\AnsiConverter\Theme\SolarizedTheme;

$theme = new SolarizedTheme();
$converter = new AnsiToHtmlConverter($theme, false);

$twig->addExtension(AnsiExtension($converter));
```

Then:

```

            {# This is only need if the inline styling is disabled #}
            {{ ansi_css }}

        {{ some_ansi_code|ansi_to_html }}

```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 64% 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 ~306 days

Recently: every ~507 days

Total

10

Last Release

2050d ago

PHP version history (3 changes)v1.0.0PHP &gt;=5.3.0

v1.2.0PHP ^7.0

v1.2.1PHP &gt;=7.2.5

### Community

Maintainers

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

---

Top Contributors

[![fabpot](https://avatars.githubusercontent.com/u/47313?v=4)](https://github.com/fabpot "fabpot (16 commits)")[![michabbb](https://avatars.githubusercontent.com/u/3524595?v=4)](https://github.com/michabbb "michabbb (2 commits)")[![jackbentley](https://avatars.githubusercontent.com/u/9383439?v=4)](https://github.com/jackbentley "jackbentley (1 commits)")[![Jean85](https://avatars.githubusercontent.com/u/6729988?v=4)](https://github.com/Jean85 "Jean85 (1 commits)")[![lyrixx](https://avatars.githubusercontent.com/u/408368?v=4)](https://github.com/lyrixx "lyrixx (1 commits)")[![maxhelias](https://avatars.githubusercontent.com/u/12966574?v=4)](https://github.com/maxhelias "maxhelias (1 commits)")[![adam187](https://avatars.githubusercontent.com/u/156628?v=4)](https://github.com/adam187 "adam187 (1 commits)")[![skolodyazhnyy](https://avatars.githubusercontent.com/u/576301?v=4)](https://github.com/skolodyazhnyy "skolodyazhnyy (1 commits)")[![cordoval](https://avatars.githubusercontent.com/u/328359?v=4)](https://github.com/cordoval "cordoval (1 commits)")

### Embed Badge

![Health badge](/badges/macropage-ansi-to-html/health.svg)

```
[![Health](https://phpackages.com/badges/macropage-ansi-to-html/health.svg)](https://phpackages.com/packages/macropage-ansi-to-html)
```

PHPackages © 2026

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