chalk
Terminal string styling for Node.js — colorize and style CLI output with a chainable, expressive API.
chalk
General JSTerminal string styling for Node.js — colorize and style CLI output with a chainable, expressive API.
Fit
Bundle (gzip)
2.7 kB
6.7 kB raw
Install size includes transitive dependencies. Bundle size is gzipped browser payload.
Freshness
The Problem
Printing colored or styled output to the terminal requires manually constructing ANSI escape codes, checking if the terminal supports color, and ensuring codes are reset after each styled string.
What It Does
Chalk provides a fluent API for applying colors, backgrounds, and text styles (bold, italic, underline) to terminal strings. It auto-detects terminal color support and degrades gracefully. Nested styles work correctly with automatic reset sequencing.
Installation
npm install chalkUsage Example
import chalk from 'chalk';
// Colors and styles
console.log(chalk.green('✓ Build succeeded'));
console.log(chalk.red.bold('✗ 3 errors found'));
console.log(chalk.yellow.italic('⚠ 2 warnings'));
// Template literals
console.log(chalk`
{blue Info:} Deploying to {underline production}
{green.bold Success:} {white 42} files uploaded
{red Error:} Connection timeout after {yellow 30s}
`);
// Dynamic highlighting
const status = (code: number) =>
code < 400 ? chalk.green(code) : chalk.red(code);Related packages
Unified TypeScript SDK for building AI-powered apps — switch between 20+ LLM providers without rewriting code.
animejsGeneral JSLightweight JavaScript animation library with a tiny footprint and a powerful, expressive API.
AOSGeneral JSAn easy-to-use library that makes elements fade, slide, or zoom into view as the user scrolls down your page.
archiverGeneral JSStreaming interface for generating ZIP and TAR archives in Node.js — create compressed archives programmatically from files, directories, and buffers.
@formkit/auto-animateGeneral JS> Add smooth transitions to any element with a single line — zero-config animations for adds, removes, and moves.