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

chalk-ts

v1.0.1

Published

๐ŸŽจ Modern terminal string styling library built with TypeScript - A better alternative to chalk with enhanced features and type safety

Downloads

257

Readme

๐ŸŽจ chalk-ts

npm version License: MIT TypeScript Test Coverage YouTube Buy Me a Coffee

๐Ÿš€ Modern terminal string styling library built with TypeScript
A powerful, feature-rich alternative to chalk with enhanced capabilities, TrueColor support, visual effects, and modern development experience.

โœจ Features

  • ๐ŸŽจ Rich Color Support: 20+ built-in colors, TrueColor (RGB/HEX/HSL)
  • ๐ŸŽญ Advanced Effects: Gradients, rainbow, pulse, neon, shadow, zebra stripes
  • ๐Ÿ› ๏ธ Built-in Utilities: Tables, progress bars, boxes, spinners
  • ๐ŸŽฏ Semantic Theming: Create reusable theme configurations
  • ๐Ÿ”’ TypeScript First: Full type safety with excellent IntelliSense
  • ๐Ÿ“ฆ Zero Dependencies: No external packages, minimal bundle size (~15KB)
  • ๐ŸŒณ Tree Shakeable: Import only what you need
  • โšก High Performance: Optimized for speed and efficiency
  • ๐Ÿ”ง Easy Migration: Drop-in replacement for most chalk usage
  • ๐ŸŒ Web Demo: Interactive browser-based demo with live examples
  • ๐Ÿ“– Comprehensive Docs: Extensive documentation and examples
  • ๐Ÿงช Well Tested: 98%+ test coverage with 98 passing tests

๐ŸŒ Interactive Demo

Try out all features in your browser: Live Web Demo

The demo includes:

  • โœ… All 20+ colors and backgrounds
  • โœ… TrueColor (RGB/HEX/HSL) examples
  • โœ… Visual effects (gradients, rainbow, neon, etc.)
  • โœ… Utilities (boxes, tables, progress bars)
  • โœ… Code snippets with copy functionality
  • โœ… Live terminal output rendering

๐Ÿ“ฆ Installation

npm install chalk-ts
yarn add chalk-ts
pnpm add chalk-ts
bun add chalk-ts

๐Ÿš€ Quick Start

import chalk from "chalk-ts";

// Basic colors
console.log(chalk.red("Hello World!"));
console.log(chalk.green.bold("Success message"));

// TrueColor support
console.log(chalk.rgb(255, 136, 0)("Custom RGB color"));
console.log(chalk.hex("#ff8800")("HEX color"));
console.log(chalk.hsl(30, 100, 50)("HSL color"));

// Method chaining
console.log(chalk.bold.red.bgYellow("Styled text"));

// Advanced effects
import { gradient, rainbow, box, createTheme } from "chalk-ts";

console.log(gradient("Gradient text!", ["#ff0000", "#00ff00", "#0000ff"]));
console.log(rainbow("Rainbow colors!"));
console.log(box("Boxed text"));

// Semantic theming
const theme = createTheme({
  info: chalk.blue.bold,
  success: chalk.green,
  error: chalk.red.bold,
});

console.log(theme.info("Info message"));
console.log(theme.success("Success!"));
console.log(theme.error("Error occurred"));

๐ŸŽจ Basic Styling

Text Styles

import chalk from "chalk-ts";

console.log(chalk.bold("Bold text"));
console.log(chalk.italic("Italic text"));
console.log(chalk.underline("Underlined text"));
console.log(chalk.strikethrough("Strikethrough text"));
console.log(chalk.dim("Dimmed text"));
console.log(chalk.inverse("Inverted text"));

Basic Colors

// Foreground colors
console.log(chalk.black("Black text"));
console.log(chalk.red("Red text"));
console.log(chalk.green("Green text"));
console.log(chalk.yellow("Yellow text"));
console.log(chalk.blue("Blue text"));
console.log(chalk.magenta("Magenta text"));
console.log(chalk.cyan("Cyan text"));
console.log(chalk.white("White text"));
console.log(chalk.gray("Gray text"));

// Background colors
console.log(chalk.bgRed("Red background"));
console.log(chalk.bgGreen("Green background"));
console.log(chalk.bgBlue("Blue background"));
console.log(chalk.bgYellow("Yellow background"));

// Bright colors
console.log(chalk.redBright("Bright red"));
console.log(chalk.greenBright("Bright green"));
console.log(chalk.blueBright("Bright blue"));
console.log(chalk.yellowBright("Bright yellow"));

Extended Color Palette

chalk-ts includes 20+ built-in colors beyond the standard ANSI colors:

console.log(chalk.orange("Orange text"));
console.log(chalk.purple("Purple text"));
console.log(chalk.pink("Pink text"));
console.log(chalk.brown("Brown text"));
console.log(chalk.lime("Lime text"));
console.log(chalk.indigo("Indigo text"));
console.log(chalk.violet("Violet text"));
console.log(chalk.turquoise("Turquoise text"));
console.log(chalk.gold("Gold text"));
console.log(chalk.silver("Silver text"));
console.log(chalk.crimson("Crimson text"));
console.log(chalk.navy("Navy text"));
console.log(chalk.teal("Teal text"));
console.log(chalk.olive("Olive text"));
console.log(chalk.maroon("Maroon text"));

๐ŸŒˆ TrueColor Support

RGB Colors (24-bit)

// Foreground RGB
console.log(chalk.rgb(255, 136, 0)("Custom Orange"));
console.log(chalk.rgb(100, 200, 255)("Sky Blue"));

// Background RGB
console.log(chalk.bgRgb(255, 136, 0)("Orange background"));
console.log(chalk.bgRgb(100, 200, 255)("Sky blue background"));

HEX Colors

// Foreground HEX
console.log(chalk.hex("#ff8800")("Orange HEX"));
console.log(chalk.hex("#64c8ff")("Sky Blue HEX"));

// Background HEX
console.log(chalk.bgHex("#ff8800")("Orange background"));
console.log(chalk.bgHex("#64c8ff")("Sky blue background"));

HSL Colors

// Foreground HSL (Hue, Saturation, Lightness)
console.log(chalk.hsl(30, 100, 50)("Orange HSL"));
console.log(chalk.hsl(200, 100, 70)("Sky Blue HSL"));

// Background HSL
console.log(chalk.bgHsl(30, 100, 50)("Orange background"));
console.log(chalk.bgHsl(200, 100, 70)("Sky blue background"));

๐ŸŽญ Visual Effects

Gradient

Create beautiful gradient effects with multiple color stops:

import { gradient } from "chalk-ts";

// Two-color gradient
console.log(gradient("Gradient Text!", ["#ff0000", "#0000ff"]));

// Multi-color gradient
console.log(gradient("Rainbow Gradient!", ["#ff0000", "#00ff00", "#0000ff"]));

// Fire effect
console.log(gradient("Fire Effect", ["#ff4500", "#ffd700"]));

// Ocean effect
console.log(gradient("Ocean Waves", ["#006994", "#00d4ff", "#7fffd4"]));

Rainbow

Apply rainbow colors to text:

import { rainbow } from "chalk-ts";

console.log(rainbow("Rainbow Colors!"));
console.log(rainbow("๐ŸŒˆ Colorful text ๐ŸŒˆ"));

Pulse

Create pulsing effects with alternating bright and dim:

import { pulse } from "chalk-ts";

console.log(pulse("Pulsing text", "red"));
console.log(pulse("Attention!", "yellow"));

Zebra Stripes

Alternate between two colors:

import { zebra } from "chalk-ts";

console.log(zebra("Zebra effect", "red", "blue"));
console.log(zebra("Alternating colors!", "green", "yellow"));

Neon Effect

Create glowing neon-style text:

import { neon } from "chalk-ts";

console.log(neon("Neon text!", "cyan"));
console.log(neon("Glowing!", "magenta"));
console.log(neon("Electric!", "blue"));

Shadow Effect

Add shadow to text:

import { shadow } from "chalk-ts";

console.log(shadow("Text with shadow", "cyan", "gray"));
console.log(shadow("Depth effect", "yellow", "black"));

๐Ÿ› ๏ธ Built-in Utilities

Boxes

Create beautiful boxes around text with various styles:

import { box } from "chalk-ts";

// Simple box
console.log(box("Hello World!"));

// Customized box
console.log(
  box("Fancy Box", {
    padding: 2,
    color: "cyan",
    style: "double",
  }),
);

// Different styles
console.log(box("Single Border", { style: "single" }));
console.log(box("Double Border", { style: "double" }));
console.log(box("Rounded Corners", { style: "rounded" }));
console.log(box("Thick Border", { style: "thick" }));

// Multi-line content
console.log(
  box("Line 1\nLine 2\nLine 3", {
    padding: 1,
    color: "green",
  }),
);

Progress Bars

Create customizable progress indicators:

import { progressBar } from "chalk-ts";

// Simple progress bar
console.log(progressBar(75, 100)); // 75% progress

// Customized progress bar
console.log(
  progressBar(50, 100, {
    width: 30,
    complete: "โ– ",
    incomplete: "โ–ก",
    color: "green",
  }),
);

// Different styles
console.log(
  progressBar(80, 100, {
    complete: "โ–ˆ",
    incomplete: "โ–‘",
    color: "cyan",
  }),
);

Tables

Create formatted tables with headers and custom styling:

import { table } from "chalk-ts";

const data = [
  ["John Doe", "28", "Developer"],
  ["Jane Smith", "34", "Designer"],
  ["Bob Johnson", "45", "Manager"],
];

const headers = ["Name", "Age", "Role"];

// Table with headers
console.log(
  table(data, {
    headers,
    headerColor: "cyan",
    borderColor: "gray",
  }),
);

// Table without headers
console.log(table(data));

// Custom styling
console.log(
  table(data, {
    headers,
    headerColor: "yellow",
    borderColor: "blue",
  }),
);

Spinners

Animated loading indicators:

import { spinner } from "chalk-ts";

// Display different frames
for (let i = 0; i < 10; i++) {
  console.clear();
  console.log(spinner(i, "cyan") + " Loading...");
  await new Promise((resolve) => setTimeout(resolve, 100));
}

// Different colors
console.log(spinner(0, "green") + " Processing...");
console.log(spinner(1, "yellow") + " Working...");
console.log(spinner(2, "magenta") + " Please wait...");

๐ŸŽฏ Semantic Theming

Create reusable theme configurations for consistent styling:

import { createTheme } from "chalk-ts";
import chalk from "chalk-ts";

// Define your theme
const theme = createTheme({
  info: chalk.blue.bold,
  success: chalk.green,
  warning: chalk.yellow.bold,
  error: chalk.red.bold.bgWhite,
  debug: chalk.gray.dim,
});

// Use the theme
console.log(theme.info("Application started"));
console.log(theme.success("โœ“ Task completed successfully"));
console.log(theme.warning("โš  Warning: Low memory"));
console.log(theme.error("โœ— Error: Connection failed"));
console.log(theme.debug("Debug: Variable value = 42"));

// Themes can use any chalk styling
const fancyTheme = createTheme({
  header: chalk.bold.underline.cyan,
  subheader: chalk.italic.blue,
  highlight: chalk.bgYellow.black.bold,
  muted: chalk.dim.gray,
});

console.log(fancyTheme.header("Main Title"));
console.log(fancyTheme.subheader("Subtitle"));
console.log(fancyTheme.highlight("Important!"));
console.log(fancyTheme.muted("Less important"));

๐Ÿ”— Method Chaining

chalk-ts supports full method chaining for complex styling:

// Combine multiple styles
console.log(chalk.bold.red.bgYellow("Complex styling"));

// Chain with TrueColor
console.log(chalk.bold.rgb(255, 100, 0).bgHex("#000000")("Custom chain"));

// Multiple text effects
console.log(chalk.bold.italic.underline.red("All effects"));

// Nested styling
console.log(
  chalk.blue("Blue text with " + chalk.red.bold("red bold") + " inside"),
);

๐Ÿ”ง Utility Methods

Strip ANSI Codes

Remove styling from text:

const styled = chalk.red.bold("Styled text");
const plain = chalk.strip(styled);
console.log(plain); // 'Styled text'

Calculate Length

Get the actual text length without ANSI codes:

const styled = chalk.red.bold("Hello");
console.log(styled.length); // Includes ANSI codes (e.g., 23)
console.log(chalk.length(styled)); // 5 (actual text length)

Template Literals

Support for template strings with embedded styling:

const name = "World";
const greeting = chalk.template`Hello {red.bold ${name}}!`;
console.log(greeting);

// More complex templates
const status = "success";
const message = chalk.template`Status: {green.bold ${status}} - All systems operational`;
console.log(message);

๐ŸŽฎ Color Level Control

Control color output levels for different environments:

import { ChalkTS } from "chalk-ts";

// Level 0: No colors
const noColors = new ChalkTS({ level: 0 });
console.log(noColors.red("Plain text"));

// Level 1: Basic 16 colors
const basicColors = new ChalkTS({ level: 1 });
console.log(basicColors.red("Basic red"));

// Level 2: 256 colors
const extendedColors = new ChalkTS({ level: 2 });
console.log(extendedColors.rgb(255, 100, 0)("Downsampled to 256"));

// Level 3: TrueColor (16 million colors)
const trueColor = new ChalkTS({ level: 3 });
console.log(trueColor.rgb(255, 100, 0)("Full RGB"));

// Auto-detect (default)
import chalk from "chalk-ts";
console.log(chalk.red("Auto-detected color level"));

๐Ÿ“Š Performance & Comparison

chalk-ts is designed for performance while providing more features:

| Library | Bundle Size | Colors | Effects | Utilities | TypeScript | Tests | | --------- | ----------- | ------ | ------- | --------- | ---------- | ----- | | chalk-ts | ~15KB | 20+ | 6+ | 4+ | โญโญโญโญโญ | 98 | | Chalk | ~17KB | 8 | 0 | 0 | โญโญโญโญ | - | | Colorette | ~8KB | 8 | 0 | 0 | โญโญโญ | - |

Why Choose chalk-ts?

  1. ๐ŸŽจ More Colors: 20+ built-in colors + TrueColor support
  2. ๐ŸŽญ Visual Effects: Gradients, rainbow, pulse, neon, shadow, zebra
  3. ๐Ÿ› ๏ธ Built-in Utilities: Tables, progress bars, boxes, spinners
  4. ๐ŸŽฏ Theming: Semantic theme system for consistent styling
  5. ๐Ÿ”’ Better Types: Full TypeScript support with strict typing
  6. ๐Ÿ“ฆ Modern Build: ES modules, tree-shaking, zero dependencies
  7. ๐Ÿงช Well Tested: 98%+ coverage with 98 passing tests
  8. ๐Ÿ“– Great Docs: Comprehensive documentation + interactive demo
  9. ๐Ÿ”ง Easy Migration: Drop-in replacement for chalk

๐Ÿ”„ Migration from Chalk

chalk-ts is designed as a drop-in replacement for chalk:

// Before (chalk)
import chalk from "chalk";
console.log(chalk.red.bold("Hello"));

// After (chalk-ts) - same API!
import chalk from "chalk-ts";
console.log(chalk.red.bold("Hello"));

// Plus new features!
import { gradient, createTheme } from "chalk-ts";
console.log(gradient("Gradient!", ["#ff0000", "#0000ff"]));

Most chalk code will work without changes, but you'll get:

  • โœ… 20+ additional colors
  • โœ… TrueColor (RGB/HEX/HSL) support
  • โœ… Visual effects (gradients, rainbow, etc.)
  • โœ… Built-in utilities (tables, boxes, etc.)
  • โœ… Semantic theming
  • โœ… Better TypeScript support

๐Ÿ“š Complete API Reference

Basic Colors

black, red, green, yellow, blue, magenta, cyan, white, gray

Bright Colors

redBright, greenBright, yellowBright, blueBright, magentaBright, cyanBright, whiteBright

Background Colors

bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bgGray

Bright Backgrounds

bgRedBright, bgGreenBright, bgYellowBright, bgBlueBright, bgMagentaBright, bgCyanBright, bgWhiteBright

Extended Colors (20+)

orange, purple, pink, brown, lime, indigo, violet, turquoise, gold, silver, crimson, navy, teal, olive, maroon

Text Styles

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

TrueColor Methods

  • rgb(r, g, b) - Foreground RGB color
  • bgRgb(r, g, b) - Background RGB color
  • hex(color) - Foreground HEX color
  • bgHex(color) - Background HEX color
  • hsl(h, s, l) - Foreground HSL color
  • bgHsl(h, s, l) - Background HSL color

Utility Methods

  • strip(text) - Remove ANSI codes from text
  • length(text) - Get text length without ANSI codes
  • template - Template literal support

Visual Effects

  • gradient(text, colors[]) - Multi-color gradient
  • rainbow(text) - Rainbow effect
  • pulse(text, color?) - Pulsing effect
  • zebra(text, color1?, color2?) - Alternating colors
  • neon(text, color?) - Neon glow effect
  • shadow(text, color?, shadowColor?) - Shadow effect

Utilities

  • box(text, options?) - Create bordered box
  • progressBar(current, total, options?) - Progress indicator
  • spinner(frame, color?) - Loading spinner
  • table(data, options?) - Formatted table

Theming

  • createTheme(config) - Create semantic theme

๐ŸŒŸ Examples

CLI Application

import chalk from "chalk-ts";
import { box, progressBar, createTheme } from "chalk-ts";

const theme = createTheme({
  info: chalk.blue.bold,
  success: chalk.green.bold,
  error: chalk.red.bold,
});

console.log(
  box("My CLI App v1.0.0", {
    padding: 1,
    color: "cyan",
    style: "rounded",
  }),
);

console.log(theme.info("Starting installation..."));
console.log(progressBar(50, 100, { color: "cyan" }));
console.log(theme.success("โœ“ Installation complete!"));

Log System

import chalk from "chalk-ts";
import { createTheme } from "chalk-ts";

const logTheme = createTheme({
  debug: chalk.gray.dim,
  info: chalk.blue,
  warn: chalk.yellow.bold,
  error: chalk.red.bold.bgWhite,
  success: chalk.green.bold,
});

class Logger {
  debug(msg: string) {
    console.log(logTheme.debug(`[DEBUG] ${msg}`));
  }
  info(msg: string) {
    console.log(logTheme.info(`[INFO] ${msg}`));
  }
  warn(msg: string) {
    console.log(logTheme.warn(`[WARN] ${msg}`));
  }
  error(msg: string) {
    console.log(logTheme.error(`[ERROR] ${msg}`));
  }
  success(msg: string) {
    console.log(logTheme.success(`[SUCCESS] ${msg}`));
  }
}

const logger = new Logger();
logger.info("Application started");
logger.success("Connected to database");
logger.warn("High memory usage detected");
logger.error("Failed to load configuration");

Data Visualization

import { table, progressBar, gradient } from "chalk-ts";

// Sales report
const salesData = [
  ["Product A", "$1,234", "โ†‘ 15%"],
  ["Product B", "$2,456", "โ†‘ 23%"],
  ["Product C", "$987", "โ†“ 5%"],
];

console.log(gradient("SALES REPORT", ["#00d4ff", "#7fffd4"]));
console.log(
  table(salesData, {
    headers: ["Product", "Revenue", "Change"],
    headerColor: "cyan",
    borderColor: "gray",
  }),
);

console.log("\nQuarterly Progress:");
console.log(
  progressBar(75, 100, {
    width: 40,
    color: "green",
    complete: "โ–ˆ",
    incomplete: "โ–‘",
  }),
);

Check out more examples:

๐Ÿงช Testing

Run the test suite:

npm test

Run tests with coverage:

npm run test:coverage

Run demo:

npm run demo

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ“„ License

MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

Inspired by:

  • chalk - The original terminal styling library
  • Thanks to all contributors and the open source community

๐Ÿ“ž Support

If you have any questions or need help, please:

๐ŸŽ‰ Show Your Support

If this library helped you, please give it a โญ๏ธ on GitHub!

You can also support the development of this project by buying me a coffee:


Made with โค๏ธ by Noor Mohammad

โญ Star this repo if you find it useful!