npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@artiq/stylize

v1.0.4

Published

Lightweight terminal text stylizer with ANSI, RGB, HEX colors, multiple styling modes, and chainable proxy API.

Downloads

25

Readme

npm License ESM Node

@artiq/stylize

A minimalist ANSI styling tool for text formatting — made for simplicity, flexibility, and extensibility.


✨ Key Features

  • 🎨 Rich Styling Support – ANSI modifiers, foreground/background colors, 8-bit RGB, HEX
  • 🔗 Chainable Proxy API – Use .bold.red.bgBlue(...) with full IntelliSense
  • ⚙️ Flexible Application – Apply styles per character, word, line, or sentence
  • 🧪 Runtime Safe – Auto-validates styles and mode usage

📦 Installation

npm install @artiq/stylize

This package is ESM only, make sure you have "type": "module" in your package.json.


🎨 Supported Styles

Modifiers

bold, dim, italic, underline, inverse, hidden, strikethrough

Foreground Colors

black, red, green, yellow, blue, magenta, cyan, white,
gray, brightRed, brightGreen, brightYellow, brightBlue, brightMagenta, brightCyan, brightWhite

Background Colors

Prefix with bg + capitalized color, e.g.:

bgRed, bgBlue, bgGreen, bgBrightCyan, bgWhite, etc.

Each word will receive a random style from the styleSets.


📘 API Reference

stylize(text, styleSets, options?)

| Param | Type | Description | |-------------|--------------|-----------------------------------------------------| | text | string | The raw text to stylize | | styleSets | string[][] | Array of style groups | | options | object | Optional: style (mode), randomize (boolean) |


resolveAnsiStyles(styles: string[])

Resolve an array of styles to a single ANSI escape sequence.


🚀 Getting Started

Import package

import stylize from '@artiq/stylize';

Basic Style

console.log(stylize(
  'HELLO ARTIQ',
  [['bold', 'red']],
  { style: 'word' }
));

console.log(stylize('HELLO STYLIZE', [['italic', 'green']]));

Result: Basic Style 1
Basic Style 2


Using Multiple Styles (styleSets)

const styleSets = [
  ['green', 'bold'],
  ['blue', 'italic'],
  ['yellow', 'dim'],
  ['magenta'],
  ['cyan', 'underline']
];

console.log(stylize(
  'Stylize is fun and colorful!',
  styleSets,
  { style: 'word' }
));

Result: Multiple Stylize


Available Modes

| Mode | Description | |------------|---------------------------| | char | Apply style per character | | word | Apply style per word | | line | Apply style per line | | sentence | Apply style per sentence |


🧩 Proxy API (Chaining Style)

console.log(
  stylize.yellow.bold.underline('HELLO ARTIQ STYLIZE')
);

Result: Chaining Style


Custom RGB & HEX

const stylesRGB = [
  ['bold', 'rgb(255,0,0)'],
  ['underline', 'rgb(0,255,0)'],
  ['italic', 'rgb(0,0,255)'],
  ['bgRgb(255,255,0)', 'black']
];

console.log(
  stylize('Hello colorful style rgb', stylesRGB, { style: 'word', randomize: false })
);

const stylesHEX = [
  ['#00FFFF', 'underline'],
  ['#ff0000', 'strikethrough'],
  ['bg#00FF00'],
  ['bg#333333'],
  ['dim']
];

console.log(stylize('Hello colorful style hex', stylesHEX, { style: 'word' }));

Result: RGB
HEX


🔀 Advanced: Random & Gradient Application

Randomize Style per Segment

console.log(stylize(
  'Random style fun',
  [['red'], ['blue', 'italic'], ['green', 'underline']],
  { style: 'word', randomize: true }
));

Result: Randomize Style


👤 Author

Dimas Fajar


⚖️ License

This project is licensed under the MIT License – see the LICENSE file for details.