# chalk — card for AI agents

Terminal string styling library for colorful and formatted CLI output.

Category: Dev workflow and config · npm package `chalk` · latest version 6.0.1 (checked 2026-11-01)
Install: `npm install chalk`
License: MIT (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Agent Skills for it
- chalk-logic from CaliCastle/skills: `npx skills add CaliCastle/skills --skill chalk-logic`

## Numbers (AgentGid data)
- Gid Score: 80.0 (#102 of all tools, 9 of 299 in its category)
- Used in 181 public projects set up for AI coding agents (2.9%)
- Downloads last week: 660,454,594 (as of 2026-11-24), +31.9% over 4 weeks
- GitHub stars: 23,346 (as of 2026-11-24)
- Last push: 2026-10-22

## Often used with
Commander 64.6%, tsx 55.8%, dotenv 52.5%, Vitest 58.6%, Express 40.9%, Zod 61.3%

## Links
- AgentGid page: https://agentgid.com/tools/chalk/
- Homepage: https://github.com/chalk/chalk#readme
- Repository: https://github.com/chalk/chalk


## chalk: colored, bold and underlined text in the terminal

chalk is a free JavaScript package that colors the messages a command-line program prints, so errors show in red and success in green. It checks whether the screen can show color and leaves plain text when it cannot. It styles terminal and browser console text, not the text on your web pages.

### Where to use it
- Readable build and deploy reports: Your deploy or setup script prints many lines; success turns green, warnings orange and errors bold red, so problems stand out at a glance.
- Plain text in log files: When the same program writes to a log file or a build server, color codes would be clutter; chalk can be set to print plain text.
- Your brand color in a command-line tool: A banner or prompt in your own command-line tool uses the exact hex color of your brand, not just the basic 16 colors.
- Check color names users type: Your tool lets people pick colors in a settings file; check each name against chalk's own list before using it.
- Separate colors for error output: Your program sends normal output to one place and errors to another; chalkStderr picks colors for the error stream on its own.
- Highlight failed checks for an assistant: A check script that your AI assistant runs prints failures in red and a short green summary, so you see the result in the chat log. (idea, not from the official pages)

### How to start
- Install chalk in a project that runs on Node.js 22 or newer.

```
npm install chalk
```

- Import it and wrap the text you print. Styles chain, and you can nest them.

```
import chalk from 'chalk';

console.log(chalk.blue('Hello world!'));
```

- To force colors on or off without code changes, set FORCE_COLOR when you run the program.

```
FORCE_COLOR=0 node build.js
```


### License
Free for any use, also in paid and closed-source products, under the MIT license. No visible credit is needed; keep the license notice if you ship chalk's own files.

### Good to know
- Version 6 needs Node.js 22 or newer. On older Node.js, stay on version 5.6.2.
- Since version 5 it loads only with import. The readme suggests version 4 for setups that cannot handle that.
- Version 5.6.1 on the package registry was a hijacked, harmful release; 5.6.2 replaced it. Pin exact versions and keep a lockfile.
- Italic, underline and strikethrough do not show in every terminal, so do not rely on them alone.
- Changing chalk.level changes it for every package in the program that uses chalk.

Checked 2026-11-10 against: https://github.com/chalk/chalk/blob/main/readme.md, https://github.com/chalk/chalk/blob/main/license, https://github.com/chalk/chalk/blob/main/package.json, https://github.com/chalk/chalk/releases/tag/v6.0.0, https://github.com/chalk/chalk/releases/tag/v6.0.1, https://github.com/chalk/chalk/releases/tag/v5.6.2, https://github.com/chalk/chalk/issues/656, https://registry.npmjs.org/chalk

### Mistakes to avoid
- Don't: const chalk = require('chalk') in a CommonJS file or a TypeScript build that outputs CommonJS → Do: Use import chalk from 'chalk' in an ESM file, or pin chalk@4 if the setup cannot load ESM (chalk 5 and later ship only as ESM.)
- Don't: npm install chalk on a project that runs Node.js 18 or 20 → Do: Run Node.js 22+, or pin chalk@5.6.2 on older Node.js (chalk 6.0.0 raised the minimum to Node.js 22 (package.json engines "node" ">=22").)
- Don't: chalk.level = 0 inside a library you publish → Do: const customChalk = new Chalk({level: 0}) and use that instance (The level property is shared by every chalk user in the same program.)
- Don't: A loose version range, or 5.6.1 kept in an old lockfile → Do: Pin an exact version (6.0.1) with a lockfile and remove 5.6.1 wherever it appears (5.6.1 was a harmful release pushed to the registry; 5.6.2 replaced it.)
- Don't: Expecting chalk.underlineRed('typo') to show a colored underline → Do: Add an underline style too, e.g. chalk.underlineRed.underlineCurly('typo') (Underline colors only show together with an underline style, and many terminals ignore them.)

### Questions
- Can I load it with require() in an older CommonJS project? Versions 5 and 6 are loaded with import. The readme suggests staying on chalk 4 if your TypeScript or build setup cannot handle that.
- How do I turn colors off for a log file? Set FORCE_COLOR=0 when you run the program, or create new Chalk({ level: 0 }) in your code.
- Does it work in the browser? Only in the developer console, which shows the color codes in Chrome since version 69. It does not style page text.
- Does it pull in other packages? No. The readme says chalk has no dependencies.

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
