BeautifulCLITerminal string styling done right — a chainable, zero-dependency library for adding color and style to Node.js CLI output.
📖

Chalk

Terminal string styling done right — a chainable, zero-dependency library for adding color and style to Node.js CLI output.

💡
Who Chalk Is for
Establish that Chalk targets Node.js developers building CLIs, test runners, bundlers, linters, and any tooling that writes styled text to a terminal. Contrast with browser environments (ANSI codes don't render there) and note that Chalk is not the right choice when raw byte-size is the only engineering constraint.
Concept
💡
Why Chalk Exists
Explain what problem Chalk solves: the terminal styling landscape is fragmented, existing tiny alternatives sacrifice API ergonomics or correct color-level detection. Chalk trades a few extra kilobytes for a readable chainable API, conservative defaults, and long-term stability. Covers the "Why not a smaller library?" and "Who uses Chalk?" angles from the FAQ.
Concept
💡
Core Concepts
Explain the mental model before any code: styles are composable functions returning strings; chaining applies styles left-to-right; nesting resets correctly at each boundary; color output is gated by a detected level (0–3) and degrades gracefully. String.prototype is never extended.
Concept
📖
Installation
Cover npm installation, the Node.js 16+ requirement, and the ESM-only constraint of Chalk 5. Show the canonical import statement. Warn clearly that require('chalk') throws in v5 and direct CommonJS users to pin chalk@4 or migrate to ESM.
Guide
🚀
Quick Start
Minimal working example: import, call a style function, chain styles, store reusable style instances. Should produce a first success in under two minutes. Covers the basic-usage intent from the GitBook.
Tutorial
🔌
API Reference
Exhaustive reference generated from source. Cover all modifiers (reset, bold, dim, italic, underline, overline, inverse, hidden, strikethrough, visible), all named foreground colors and their Bright variants (including gray/grey aliases), all background colors and their Bright variants, Truecolor methods (hex, rgb, ansi256) and their bg equivalents, chalk.level read/write, the supportsColor export (.hasBasic, .has256, .has16m), and the Chalk constructor (new Chalk({level})).
API reference+5 sub-pages
📖
Configuration and Color Level Control
Explain the four color levels, how auto-detection works, FORCE_COLOR environment variable, programmatic override via chalk.level, and the supportsColor API. Covers the "colors don't show up" FAQ scenario and the piped/captured-output case.
Guide
📝
Troubleshooting
Address the most common failure modes derived from code and FAQ: colors absent because output is not a TTY (piped or captured), FORCE_COLOR workaround, chalk in browser consoles (ANSI codes won't render), and CommonJS require() throwing in v5.
Runbook
📖
Chaining and Nesting Styles
Deep-dive on composing styles through chaining (left-to-right application) and nesting (correct boundary resets). Show reusable style aliases. Note the removal of the tagged-template-literal syntax in v5 and the chalk-template package as the alternative.
Guide
📖
Creating Custom Chalk Instances
Explain when and why to construct new Chalk({level}) — isolated level for tests, forcing Truecolor for a specific stream, or a no-op level-0 instance for conditional color disabling without call-site branching.
Guide
📖
Migrating From Chalk 4 to Chalk 5
Enumerate every breaking change: ESM-only packaging (replace require with import), Node.js 16 minimum, removal of tagged template literals (migrate to function API or chalk-template), and new Chalk() replacing new chalk.Instance(). Reassure that the styling API itself is unchanged — chalk.color(...) call sites need only the import change.
Guide