PHPackages                             nafisc/ansi-util - 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. nafisc/ansi-util

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

nafisc/ansi-util
================

An ANSI library for PHP

v1.2(6y ago)31.7kMITPHP

Since May 18Pushed 6y ago2 watchersCompare

[ Source](https://github.com/nathan-fiscaletti/ansi-util)[ Packagist](https://packagist.org/packages/nafisc/ansi-util)[ RSS](/packages/nafisc-ansi-util/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (3)DependenciesVersions (4)Used By (0)

PHP ANSI Utility
================

[](#php-ansi-utility)

> Allows you to create ANSI strings with ease in PHP.

[![StyleCI](https://camo.githubusercontent.com/04f6c979b729acb002089cec6d61fd9c802bd7a280da059a58c18be5a5b6fae8/68747470733a2f2f7374796c6563692e696f2f7265706f732f3138373339303337392f736869656c643f7374796c653d666c6174)](https://styleci.io/repos/187390379)[![Total Downloads](https://camo.githubusercontent.com/b238190f2cb6f6e674e4da49edb6101f88bcae19f5db4c1252ff793def270b67/68747470733a2f2f706f7365722e707567782e6f72672f6e61666973632f616e73692d7574696c2f646f776e6c6f6164733f666f726d61743d666c6174)](https://packagist.org/packages/nafisc/ansi-util)[![Latest Stable Version](https://camo.githubusercontent.com/3e5622e15b274e0c4870544e9731def872a4861f60d8c73eef04063391185dcd/68747470733a2f2f706f7365722e707567782e6f72672f6e61666973632f616e73692d7574696c2f762f737461626c653f666f726d61743d666c6174)](https://packagist.org/packages/nafisc/ansi-util)[![Latest Unstable Version](https://camo.githubusercontent.com/ab5681b71339e85edf1dd8f7cecb7a57ad7c73bc118174b16c26df50294f2cff/68747470733a2f2f706f7365722e707567782e6f72672f6e61666973632f616e73692d7574696c2f762f756e737461626c653f666f726d61743d666c6174)](https://packagist.org/packages/nafisc/ansi-util)[![License](https://camo.githubusercontent.com/c7ea0c6b1a4b3a3436c7540e47837e6328cf8aef9d051ef84e9a665b3f95ed50/68747470733a2f2f706f7365722e707567782e6f72672f6e61666973632f737061636b6c652f6c6963656e73653f666f726d61743d666c6174)](https://packagist.org/packages/nafisc/ansi-util)

[![Java](https://camo.githubusercontent.com/c42d95a97295573ce768b577d07a466e2646cacdf547befecfc5ffe9ab5fdbfa/68747470733a2f2f66726565637261636b66696c65646f776e6c6f61642e636f6d2f636f6e74656e742f696d672f696d674c6f676f2f6a6176612d362d6c6f676f2e706e67)](https://camo.githubusercontent.com/c42d95a97295573ce768b577d07a466e2646cacdf547befecfc5ffe9ab5fdbfa/68747470733a2f2f66726565637261636b66696c65646f776e6c6f61642e636f6d2f636f6e74656e742f696d672f696d674c6f676f2f6a6176612d362d6c6f676f2e706e67) Java Version: [See here](https://gist.github.com/nathan-fiscaletti/9dc252d30b51df7d710a)

Usage
-----

[](#usage)

> Note: It is not guaranteed that all of these ANSI codes will work on all terminals. See [here](https://misc.flogisoft.com/bash/tip_colors_and_formatting#terminals_compatibility) for a list of compatible terminals.

```
$stringBuilder = new \Ansi\StringBuilder;

echo $stringBuilder
         ->raw('Hello, ')
         ->underline('John Doe')
         ->resetUnderline()
         ->raw('. ')
         ->raw('This is ')
         ->color16(\Ansi\Color16::FG_RED, 'red')
         ->raw('.')
         .PHP_EOL;
```

[![Result](https://camo.githubusercontent.com/35016e15362f4ab52a578e64a83e3ca4d06d6609158e3407c58358b36060aeba/68747470733a2f2f692e696d6775722e636f6d2f7334656b5531382e706e67)](https://camo.githubusercontent.com/35016e15362f4ab52a578e64a83e3ca4d06d6609158e3407c58358b36060aeba/68747470733a2f2f692e696d6775722e636f6d2f7334656b5531382e706e67)

### `\Ansi\StringBuilder`

[](#ansistringbuilder)

> Note: Each of these functions takes an optional `string` parameter which will be added immediately after the ANSI code is applied. They also all follow the [Fluent Design Pattern](https://en.wikipedia.org/wiki/Fluent_interface). The string builder itself implements the `__toString` magic method, and as such can be treated as a string.

MethodResult`bold()`Sets the bold flag.`dim()`Sets the dim flag.`underline()`Sets the underline flag.`blink()`Sets the blink flag.`invertColor()`Set the invert colors flag.`hide()`Sets the hidden flag.`reset()`Resets all colors and flags to default.`resetBold()`Resets the bold flag.`resetDim()`Resets the dim flag.`resetUnderline()`Sets the underline flag.`resetBlink()`Resets the blink flag.`resetInvertColors()`Resets the invert colors flag.`resetHidden()`Resets the hidden flag.`color16(int)`Sets the current 16-bit foreground or background color. (See `\Ansi\Color16`)`color256(int)`Sets the current 256-bit color. (See [here](https://misc.flogisoft.com/bash/tip_colors_and_formatting#colors1) for a list of color codes.)`backgroundColor256(int)`Sets the current 256-bit background color. (See [here](https://misc.flogisoft.com/bash/tip_colors_and_formatting#colors1) for a list of color codes.)#### Utility Methods

[](#utility-methods)

MethodResult`raw(string)`Adds a raw string.`ansi(value)`Escapes and appends a custom ANSI value.`stripAnsi()`Removes all ANSI sequences from the StringBuilder.`empty()`Empties out the StringBuilder.### `\Ansi\Color16`

[](#ansicolor16)

The `Color16` class is a utility class for 16-bit color codes.

> Note: Each of these constants needs to be prefixed with either `FG_` when using it as a foreground color or `BG_` when using it as a background color.

```
RESET
BLACK
RED
GREEN
YELLOW
BLUE
MAGENTA
CYAN
LIGHT_GRAY
DARK_GRAY
LIGHT_RED
LIGHT_GREEN
LIGHT_YELLOW
LIGHT_BLUE
LIGHT_MAGENTA
LIGHT_CYAN
WHITE

```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity61

Established project with proven stability

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

3

Last Release

2553d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/663ed2be1317f25f09a19e22b0ca8b0d33c3a5838267693f9848902a41e047b5?d=identicon)[nathan-fiscaletti](/maintainers/nathan-fiscaletti)

### Embed Badge

![Health badge](/badges/nafisc-ansi-util/health.svg)

```
[![Health](https://phpackages.com/badges/nafisc-ansi-util/health.svg)](https://phpackages.com/packages/nafisc-ansi-util)
```

###  Alternatives

[hekmatinasser/notowo

This Package helps developers change number to word for all language on Laravel freamwork PHP

32510.4k2](/packages/hekmatinasser-notowo)

PHPackages © 2026

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