ANSI Fragments for CLI Styling

JSON →
library 0.2.1 ·javascript
verified May 27, 2026

ansi-fragments is a compact JavaScript library designed for constructing aesthetically pleasing command-line interface (CLI) outputs using ANSI escape codes. Currently at version 0.2.1, it adopts a unique builder-pattern approach, allowing developers to compose styled text fragments programmatically. The library provides functions like `color`, `modifier`, `container`, `pad`, `fixed`, `ifElse`, and `provide` to encapsulate styling logic. Its core differentiator is the explicit fragment building and the `.build()` method, which converts the fragment tree into a single ANSI-encoded string. While a relatively new project, its focus is on providing a 'nice DX' for structured CLI logging rather than offering an exhaustive list of all possible ANSI features. Release cadence is infrequent, typical for a micro-utility library in its early stages.

total hits 32
actors 10 distinct systems
last hit 2d ago Amazonbot
Amazonbot
4
MetaBot
4
ByteDance
3
GPTBot
2
Script
1
CommonCrawl
1
Search engines
2
Humans
7

top countries 🇺🇸 United States · 🇩🇪 Germany · 🇸🇬 Singapore · VN · 🇨🇦 Canada