🛠️
Utility200M+/wkMIT

chalk

Chalk is the most popular library for styling terminal string output with colors and formatting in Node.js. The library provides a chainable API for applying fo

Installation

npm
npm install chalk
yarn
yarn add chalk
pnpm
pnpm add chalk

Import

ESM
import chalk from 'chalk';

Quick Example

usage
import chalk from 'chalk';

console.log(chalk.red.bold('Error: ') + 'Something went wrong');
console.log(chalk.green('✓ ') + 'Tests passed');
console.log(chalk.bgBlue.white(' INFO ') + ' Processing...');
console.log(chalk.hex('#FF8800')('Custom color'));

About chalk

Chalk is the most popular library for styling terminal string output with colors and formatting in Node.js. The library provides a chainable API for applying foreground colors, background colors, and text modifiers (bold, italic, underline, strikethrough, dim, inverse) to strings printed to the terminal. Chalk uses ANSI escape codes that work across Windows, macOS, and Linux terminals, with automatic color support detection that gracefully disables colors when output is piped or the terminal does not support them. The API is expressive: chalk.red.bold('Error!'), chalk.bgYellow.black('Warning'), chalk.hex('#FF8800')('Custom'). Chalk supports the full spectrum of color options including named colors (red, green, blue, etc.), RGB values, hex codes, and ANSI 256 color palette. Chalk v5+ is ESM-only, while v4 supports CommonJS for backward compatibility. The library handles nested styles correctly and provides template literal support through chalk.level configuration. Chalk is used by virtually every Node.js CLI tool that produces colored output, including npm, Yarn, ESLint, Prettier, Jest, and hundreds of others. It sets the standard for terminal string styling in the JavaScript ecosystem.

Quick Facts

Packagechalk
CategoryUtility
Weekly Downloads200M+
LicenseMIT
Installnpm install chalk

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.