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 🙏

© 2026 – Pkg Stats / Ryan Hefner

coloriz

v1.2.1

Published

String Extensions for Styling Text with Chalk

Downloads

20

Readme

Coloriz

Coloriz is a lightweight extension of Chalk that enhances the String prototype to make styling terminal output more intuitive and expressive.

Instead of calling functions like chalk.red("text"), you can now simply write "text".red or "text".bld.bgYellowBright.

Note: Coloriz is not a replacement for Chalk — it uses Chalk under the hood. It's a syntactic enhancement, not a standalone coloring engine.

Illustration

✨ Features

  • Extends String.prototype with style and color properties
  • Fully powered by Chalk
  • Supports:
    • Legacy ANSI colors (16/32 colors)
    • Bright and background variants
    • Text styles (bold, italic, underline, etc.)
    • Additional utility functions: .rgb(), .hex(), .ansi256(), .clearANSI, .transform() property.
  • Zero configuration — import once and use everywhere
  • Retrieve the chalk instance (useful for retrieving methods and properties. No install chalk)
  • Works in both JavaScript and TypeScript

🚀 Installation

npm install coloriz

⚠️ Requires Node.js v16+

📦 Usage

JavaScript

require("coloriz");

console.log("Hello".green);
console.log("Info".bgCyan.italic);
console.log("Error".red.underline);
console.log("Debug".bgBlackBright.dim);

// Custom text colros
console.log("Custom Color".rgb(128, 0, 128));
console.log("Custom Hex".hex("#ff5733"));
console.log("Ansi256".ansi256(45));

// Custom background colors
console.log("Custom Background color".bgRgb(128, 0, 128));
console.log("Custom Background Hex".bgHex("#ff5733"));
console.log("Custom Background Ansi256".bgAnsi256(45));

// Clear ANSI codes (ex: for writing in file)
console.log("Clear ANSI".green.clearANSI);

// transform function
const condition = true;
console.log(
  "Hello, World!".transform(s => condition ? s.green : s.red)
)

// Retrieve the chalk instance
const chalk = "".chalk;

TypeScript ❤️

import "coloriz";

console.log("Hello".green);
console.log("Info".bgCyan.italic);
console.log("Error".red.underline);
console.log("Debug".bgBlackBright.dim);

// Custom text colros
console.log("Custom Color".rgb(128, 0, 128));
console.log("Custom Hex".hex("#ff5733"));
console.log("Ansi256".ansi256(45));

// Custom background colors
console.log("Custom Background color".bgRgb(128, 0, 128));
console.log("Custom Background Hex".bgHex("#ff5733"));
console.log("Custom Background Ansi256".bgAnsi256(45));

// Clear ANSI codes (ex: for writing in file)
console.log("Clear ANSI".green.clearANSI);

// transform function
const condition = true;
console.log(
  "Hello, World!".transform(s => condition ? s.green : s.red)
)

// Retrieve the chalk instance
const chalk = "".chalk;

🎨 Available Properties

🎯 Text Styles

| Property | Description | | --------------- | ------------------------------ | | reset | Reset all styles | | bld | Bold | | dim | Dim | | italic | Italic | | underline | Underlined | | inverse | Inverted foreground/background | | hidden | Hidden | | strikethrough | Strike-through |

🎨 Text Colors

| Color 16/32 | Bright Variant | | ----------- | ---------------- | | black | | | red | redBright | | green | greenBright | | yellow | yellowBright | | blue | blueBright | | magenta | magentaBright | | cyan | cyanBright | | white | whiteBright | | gray | (bright black) |

🎨 Background Colors

| Color 16/32 | Bright Variant | | ----------- | ----------------- | | bgBlack | bgBlackBright | | bgRed | bgRedBright | | bgGreen | bgGreenBright | | bgYellow | bgYellowBright | | bgBlue | bgBlueBright | | bgMagenta | bgMagentaBright | | bgCyan | bgCyanBright | | bgWhite | bgWhiteBright |

🎨 Custom Color Functions

You can also use functions to apply custom colors:

Text colors

| Function | Example usage | |----------------|----------------------------------------------| | .rgb(r, g, b) | "hello".rgb(255, 0, 128) | | .hex("#RRGGBB")| "hi".hex("#ffcc00") | | .ansi256(n) | "good bye".ansi256(45) |

Background colors

| Function | Example usage | |----------------|----------------------------------------------| | .bgRgb(r, g, b) | "hello".bgRgb(255, 0, 128) | | .bgHex("#RRGGBB")| "hi".bgHex("#ffcc00") | | .bgAnsi256(n) | "good bye".bgAnsi256(45) |

🧹 Utility

| Name | Description | |------------------|-----------------------------------------------| | .clearANSI | String property to strip ANSI codes | | .transform(fn) | Apply a transformation function to the string | | .chalk | Retrieve the underlying Chalk instance |

🧠 Notes

  • You must import "coloriz" once in your entry point (e.g., main.ts, index.js)
  • Designed for CLI tools, custom loggers, and developer UX
  • Extensions are non-enumerable and do not pollute object iteration

🛠️ Advanced Usag

If you need to access the underlying Chalk instance, you can do so by extracting it from .chalk to a string.

const chalk = "".chalk;

This allows you to use all Chalk methods and properties directly, without needing to install Chalk separately.

🦺 Why Not Just Use Chalk?

You still are!
Coloriz is built entirely on top of Chalk. It doesn't replace it — it simplifies how you use it.

| Chalk | Coloriz | |----------------------------|-------------------------| | chalk.red("Hi") | "Hi".red | | chalk.bold.green("Ok") | "Ok".green.bld | | chalk.hex("#f00")("Hi") | "Hi".hex("#f00") |

⚡ Github

--> GitHub repository

📌 ChangeLog

--> Changelog

📄 License

MIT © Oignontom8283