| Library | Colors support | Features | ||||
|---|---|---|---|---|---|---|
- ESM | CJS- named import - naming colors |
16 | 256 | 16m | 🌐 | Fallback | Chained syntax |
Nested template strings `${}` |
LF\n |
Supports ENV vars CLI flags |
ansisESM CJS✅ named import✅ standard
|
✅ ✅ ✅ ✅ | →256 →16 →b&w |
✅ | ✅ | ✅ | NO_COLORFORCE_COLORCOLORTERM--no-color--color |
chalk v5ESM❌ named import✅ standard |
✅ ✅ ✅ ✅ | →256 →16 →b&w |
✅ | ❌ | ✅ | NO_COLORFORCE_COLOR--no-color--color |
koloristESM CJS✅ named import❌ standard |
✅ ✅ ✅ ❌ | →256 →b&w |
❌ | ❌ | ❌ | NO_COLORFORCE_COLOR |
cli-colorCJS❌ named import✅ standard |
✅ ✅ ❌ 🛑 | →16 →b&w |
✅ | ❌ | ❌ | NO_COLOR |
colors-cliCJS❌ named import❌ standard |
✅ ✅ ❌ 🛑 | →b&w | ✅ | ❌ | ✅ | --no-color--color |
colors.jsCJS❌ named import❌ standard |
✅ ❌ ❌ 🛑 | →b&w | ✅ | ❌ | ✅ | FORCE_COLOR--no-color--color |
ansi-colorsCJS❌ named import✅ standard |
✅ ❌ ❌ ❌ | ❌ | ✅ | ❌ | ✅ | FORCE_COLOR |
coloretteESM CJS✅ named import✅ standard |
✅ ❌ ❌ 🛑 | →b&w | ❌ | ❌ | ❌ | NO_COLORFORCE_COLOR--no-color--color |
picocolorsCJS❌ named import✅ standard |
✅ ❌ ❌ ❌ | →b&w | ❌ | ❌ | ❌ | NO_COLORFORCE_COLOR--no-color--color |
tinyrainbowESM❌ named import✅ standard |
✅ ❌ ❌ ✅ | →b&w | ❌ | ❌ | ❌ | NO_COLORFORCE_COLORFORCE_TTY--no-color--color |
kleurESM CJS✅ named import✅ standard |
❌ ❌ ❌ ✅8 colors |
→b&w | ✅ | ❌ | ❌ | NO_COLORFORCE_COLOR |
util.styleText()Node ≥ 22❌ named import✅ standard |
✅ ❌ ❌ 🛑 | →b&w | ❌ | ❌ | ? | NO_COLORFORCE_COLOR |
Named import
- ESM:
import { red, green, blue } from 'lib'; - CJS:
const { red, green, blue } = require('lib');
Naming colors
- standard: colors have standard names, e.g.:
red,redBright,bgRed,bgRedBright - non-standard: colors have lib-specific names, e.g.:
brightRed,bgBrightRed,red_b,red_btt
-
16- ANSI 16 colors likered,redBright,bgRed,bgRedBright -
256- ANSI 256 colors methods, e.g.:- [
ansis][ansis]:fg(n),bg(n) - [
chalk][chalk]:ansi256(n),bgAnsi256(n) - [
cli-color][cli-color]:xterm(n) - [
colors-cli][colors-cli]:x<n>
- [
-
16m- Truecolor methods, e.g.:hex(),bgHex(),rgb(),bgRgb() -
🌐 - Colored output in Chromium-based browser console:
- ✅ - colored output
- ❌ - b&w output
- 🛑 - fatal error by compilation or in runtime
-
Fallback - Truecolor → 256 colors → 16 colors → no colors
