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

excolor

v1.2.0

Published

This package allows you to easily set text with colors, background colors, and effects in your terminal. With this package, you can customize your messages and make your terminal more visually appealing and easy to read.

Readme

exColor

exColor is a package that allows you to easily apply text colors, background colors, and effects in your terminal. With this package, you can customize your messages to make your terminal output more visually appealing and readable.

Requirements

| Technology | Version | | -------------- | ---------------- | | Node | 16.7.0 or higher | | NPM | 10.8.2 |

Installation

  1. Open a terminal at the root of your project

  2. Execute

    npm i excolor

Usage

To use exColor with ES6 syntax, you can do so as follows:

import logs from "excolor";
logs("%[yellow] Hello world of color ");

You can combine different color and effect operators in a single exColor string by separating them with the | character. This feature allows you to apply multiple styles simultaneously, creating custom text combinations.

In the example:

import logs from "excolor";
logs("%[yellowBright|bgRed|blink] Hello world of color ");

The following operators are combined:

  • yellowBright: Applies a bright yellow text color.
  • bgRed: Sets a red background.
  • blink: Makes the text blink.

This combination creates text with bright yellow color on a red background that blinks. You can mix any number of color operators (foreground and background) and effects (like bold, italic, underline, etc.) to achieve the desired style.

This flexibility allows you to create complex and styled text outputs in the terminal.

Key Features

Text Colors (foreground color)

You can apply basic colors and their bright variants. Examples:

  • Basic Colors: black, red, green, yellow, blue, magenta, cyan, white.

  • Bright Colors: blackBright, redBright, greenBright, yellowBright, blueBright, magentaBright, cyanBright, whiteBright.

import logs from "excolor";
logs("%[red]This text is red");
logs("%[greenBright]This text is bright green");

Background Colors

Set background colors for your text:

  • Basic Backgrounds: bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite.

  • Bright Backgrounds: bgBlackBright, bgRedBright, bgGreenBright, bgYellowBright, bgBlueBright, bgMagentaBright, bgCyanBright, bgWhiteBright.

import logs from "excolor";
logs("%[bgBlue]This text has a blue background");
logs("%[bgRedBright]This text has a bright red background");

Text Effects

exColor allows you to add effects like:

  • Bold: bold
  • Dim: dim
  • Italic: italic
  • Underline: underline
  • Blink: blink
  • Invert (swaps text and background): invert
  • Hide: hide
  • Strikethrough: strike
import logs from "excolor";
logs("%[bold]This text is bold");
logs("%[underline|red]This text is underlined and red");
logs("%[blink]This text will blink");

256-Color Mode

In 256-color mode, you can use ANSI's 256-color palette, which provides a wide range of color options for both text and background. This palette includes:

  • 16 basic colors (from 0 to 15)
  • 216 colors in various shades created by combining RGB values (from 16 to 231)
  • 24 grayscale colors (from 232 to 255)

You can set the text color using fg256(number) and the background color using bg256(number).

import logs from "excolor";
logs("%[fg256(82)]This is a custom 256 color text");
logs("%[bg256(124)]This text has a custom 256 color background");

Reset Operators

exColor provides specific operators to reset text color, background color, and effects to the terminal’s default settings. These operators allow you to clear any styling and return to the terminal’s original look.

Reset Operators

  • !bg or !background:

    • Resets the background color to the terminal's default.
    • Usage: %[!bg] or %[!background]
  • !fg or !color:

    • Resets the text color to the terminal's default.
    • Usage: %[!fg] or %[!color]
  • normal, reset, or "" (empty string):

    • Resets all styles, colors, and effects to the terminal's default settings.
    • Usage: %[normal], %[reset], or simply %[]

Examples

// Text with a red background and white text, then reset to the default background
logs("%[white|bgRed]Important Message%[!bg] now with default background");

// Text with bold effect and green color, then reset text color
logs("%[green|bold]Green Bold Text%[!fg] default text color");

// Text with underline and blue color, then reset all styles
logs("%[blue|underline]Underlined Text%[reset] default text and style");

These reset operators allow for fine control over styling, making it easy to return to default colors or clear specific effects without affecting the rest of the terminal's styling.

RGB and Hexadecimal Colors

For more customization, you can specify colors in RGB and Hexadecimal formats.

  • RGB: rgb(r,g,b) for text and bgRgb(r,g,b) for background.

    The RGB format allows you to specify colors by setting values for Red (R), Green (G), and Blue (B). Each of these components can take an integer value between 0 and 255, where:

    • r (Red) represents the intensity of the red component.
    • g (Green) represents the intensity of the green component.
    • b (Blue) represents the intensity of the blue component.

    For example, rgb(255,0,0) produces a bright red color (maximum intensity of red and no green or blue), while rgb(0,255,0) produces a bright green.

    Example:

    import logs from "excolor";
    logs("%[rgb(255,151,0)]This text is colored rgb(255,151,0)");
    logs("%[bgRgb(69,42,4)|white]This text has a background color in RGB");
  • Hexadecimal: hex(#RRGGBB) for text and bgHex(#RRGGBB) for background.

    The Hexadecimal format represents colors using a six-digit hexadecimal code, where each pair of digits corresponds to one of the RGB components:

    • RR is the hexadecimal value for the red component.
    • GG is the hexadecimal value for the green component.
    • BB is the hexadecimal value for the blue component.

    Each pair can range from 00 (0 in decimal) to FF (255 in decimal), allowing for 256 possible values per color channel. For example, #FF5733 represents a reddish-orange color, where FF is the maximum red, 57 is a moderate amount of green, and 33 is a small amount of blue.

import logs from "excolor";
logs("%[hex(#1F44A7)]This text is colored hex(#1F44A7)");
logs("%[bgHex(#7A0000)|hex(#ee3)]background color with text color in hex");

Example in example.js

The example.js file included in the project provides detailed examples of all these features. Run this file to see the colors and effects in action and verify the functionality of the package.

If you want to run the excolor example script, use the following command:

npm explore excolor -- npm run example