Chalk

The most popular Node.js library for styling terminal string output with ANSI colors.

Library
npm
v6.0.0
23,319 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
72 /100 Good
Development Activity 72
Maintenance 48
Community 68
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
86 /100 Excellent
Architecture 82
Code Quality 88
Innovation 85
Learning Curve 90

Chalk is a zero-dependency JavaScript library for styling text printed to a terminal. It provides a chainable, composable API for applying colors, background colors, and text modifiers like bold, underline, and dim, and it automatically detects the terminal’s color support level so output degrades gracefully in environments that can’t render truecolor or 256-color ANSI codes.

With roughly 115,000 packages depending on it and hundreds of millions of weekly downloads, Chalk is a de facto standard for CLI tooling in the Node.js ecosystem. It ships with full TypeScript definitions, supports RGB and hex color input in addition to named colors, and works identically whether styles are combined, nested, or reused as standalone builder functions.

What You Get

  • A chainable, composable styling API covering 16 base colors, bright variants, background colors, and text modifiers like bold, dim, italic, underline, and strikethrough
  • Automatic terminal color-support detection (0-3 levels: none, basic 16-color, 256-color, truecolor) via the bundled supports-color logic, with manual override support
  • RGB, hex, and ANSI256 color model support for both foreground (chalk.rgb(), chalk.hex()) and background (chalk.bgRgb(), chalk.bgHex()) styling
  • A separate chalkStderr instance pre-configured for stderr color-support detection, useful when stdout and stderr are redirected differently
  • Full TypeScript type definitions with JSDoc examples for every exported member, requiring no separate @types package
  • Zero runtime dependencies — ansi-styles and supports-color logic are vendored directly into the package

Common Use Cases

  • Coloring CLI tool output to highlight errors (red), warnings (yellow), and success messages (green) for better developer readability
  • Building custom logging themes (e.g. const error = chalk.bold.red;) reused consistently across a command-line application
  • Formatting build tool and test runner output (progress bars, diffs, pass/fail indicators) with terminal-aware styling that falls back cleanly when piped to a file
  • Adding branded ASCII banners or highlighted interactive prompts in Node.js CLI applications built with tools like Commander or Inquirer

Under The Hood

Architecture Chalk’s core (source/index.js) builds styling through a prototype-chain trick: each style getter (red, bold, bgGreen, etc.) lazily creates a “builder” function whose prototype is swapped to a shared proto object carrying all style getters, so chalk.red.bold returns a new callable builder rather than a plain object. Each builder carries a STYLER symbol holding a linked list of open/close ANSI codes (createStyler), which lets nested and chained styles compose correctly — closing codes reopen parent styles rather than terminating them outright, and a special path in applyStyle re-encases newlines so styling doesn’t bleed across line breaks in some terminals (a documented macOS bug workaround).

Tech Stack The package is pure ESM ("type": "module") with zero runtime dependencies — source/vendor/ansi-styles and source/vendor/supports-color are vendored copies of Chalk’s own sibling packages rather than npm dependencies, imported via Node’s imports field (#ansi-styles, #supports-color) so the same code resolves differently for browser vs Node builds. Dev tooling uses xo (ESLint config) for linting, ava for tests, c8 for coverage, and tsd for type-testing the .d.ts file against real usage.

Code Quality The test/ directory (chalk.js, level.js, instance.js, visible.js, no-color-support.js — around 260 lines total) exercises chaining, nesting, level-forcing, and instance isolation with concrete ANSI-escape-sequence assertions, and tsd separately validates the TypeScript surface in source/index.test-d.ts. Source files are compact (index.js ~225 lines, utilities.js 34 lines) with consistent naming and no dead code; error handling is minimal but intentional — applyOptions throws synchronously on an invalid level option rather than failing silently.

API Design The chainable chalk.color.modifier('text') pattern requires zero boilerplate — a single import and immediate use — and every exported type in index.d.ts carries inline JSDoc with runnable examples, so editor tooltips double as documentation. The API surface is deliberately narrow (style getters plus a Chalk constructor for isolated instances and level for manual overrides), trading configurability for consistency and discoverability.

Used by 98 apps in this directory

TypeScript
76%
AGPL 3.0

Abby

Developer Tools · Product Management

166

Statically typed feature flags, remote config, and A/B testing with framework-native SDKs for TypeScript teams.

View details
31
Repo Health
70
Technical
64
Dependency
Built with
TypeScript 76%
MDX 18%
Updated 1 years ago
TypeScript
100%
Other

Activepieces

AI Assistants · Automation · Mcp

24,756

Open-source AI automation platform that converts 280+ workflow integrations into MCP servers for LLMs, with no-code builders and TypeScript extensibility.

View details
92
Repo Health
85
Technical
64
Dependency
Built with
TypeScript 100%
Updated 1 weeks ago
TypeScript
82%
Other

AFFiNE

Collaboration · Note Taking · Productivity

73,040

Write, draw, and plan in one infinite canvas — the open-source alternative to Notion and Miro that keeps your data yours.

View details
91
Repo Health
87
Technical
67
Dependency
Built with
TypeScript 82%
Rust 11%
Updated 1 weeks ago
TypeScript
72%
AGPL 3.0

APITable

Databases · Low Code Platforms

15,623

API-first collaborative spreadsheet-database platform that auto-generates REST APIs and lets teams build internal tools, CRMs, and dashboards without code.

View details
71
Repo Health
77
Technical
60
Dependency
Built with
TypeScript 72%
Java 22%
Updated 1 months ago
TypeScript
96%
Other

Amplication

AI Code Assistants · Automation · Developer Tools

16,015

Create production-ready backend services with your organization's standards baked in — generating NestJS, Prisma, and GraphQL code that you own and control.

View details
58
Repo Health
84
Technical
60
Dependency
Built with
TypeScript 96%
Updated 3 months ago
JavaScript
94%
MIT

Another Redis Desktop Manager

Databases · Developer Tools

34,787

Fast, stable Redis GUI with cluster, SSH, and massive key support

View details
81
Repo Health
56
Technical
67
Dependency
Built with
JavaScript 94%
Updated 1 months ago
JavaScript
95%
MIT

AnythingLLM

AI Assistants · Automation · Developer Tools

66,533

The all-in-one AI platform for private document chat, no-code agents, and local LLMs with zero setup friction.

View details
90
Repo Health
78
Technical
64
Dependency
Built with
JavaScript 95%
Updated 1 weeks ago
TypeScript
68%
Apache 2.0

Appsmith

Automation · Developer Tools · No Code Platforms

40,959

Open-source low-code platform to build admin panels, dashboards, and internal tools connected to any database or API.

View details
93
Repo Health
79
Technical
66
Dependency
Built with
TypeScript 68%
Java 21%
Updated 1 weeks ago
TypeScript
49%
MPL 2.0

Artillery

Developer Tools · Devops

9,083

Cloud-scale load testing and functional testing for APIs, WebSockets, gRPC, and headless browsers, distributed across AWS Lambda or Fargate with zero infrastructure to manage.

View details
89
Repo Health
73
Technical
68
Dependency
Built with
TypeScript 49%
JavaScript 48%
Updated 2 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers