Chalk 6.0.0: Terminal String Styling for Node.js CLIs
đź–Ť Terminal string styling done right
At a glance
- What is it?
- Chalk is a dependency-free JavaScript library for ANSI color and style in terminal output. Version 6.0.0 requires Node.js 22 or newer and ships as ESM only, which is the main decision point for anyone still on older runtimes.
- Who is it for?
- Adopt Chalk if you maintain a Node.js 22+ CLI that needs composable ANSI styling with no dependencies and you want the color level handled for you. Do not adopt it if you are pinned to Node.js 18 or 20, or if you need CommonJS require() without a build step, since Chalk 5 and later are ESM only.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 3 days ago.
- What is it written in?
- Mainly JavaScript, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on September 29, 2026, and from our analysis. They are not legal advice.
Editorial analysis
The problem Chalk solves for Node.js command line tools
A terminal only understands escape sequences. To print a red word you have to wrap it in the right bytes, remember to reset the style afterward, and handle the case where the output is piped to a file or a CI log where color codes would show up as garbage. Chalk packages that work behind a chainable API. The audience is Node.js developers writing CLIs, build scripts, test reporters, or logging helpers. The README lists the design constraints it holds to: no dependencies, no extension of String.prototype, and automatic color detection. Those three choices explain most of the API surface. Because it does not touch String.prototype, you import a function and call it rather than calling a method on a literal. Because it has no dependencies, the package.json files field ships only source, with ansi-styles and supports-color vendored internally through the #ansi-styles and #supports-color import maps.
How the chainable style API and color detection work
Every style is a property on the default export, and each one returns a callable object that also carries the other styles. That is what makes chalk.blue.bgRed.bold('Hello world!') work: each property access returns the same kind of object with an accumulated style set, and calling it with a string applies the escape codes. Order does not matter, and later styles win on conflict, so chalk.red.yellow.green is equivalent to chalk.green. Nesting works because the library re-applies the outer style after an inner one closes, which the README demonstrates with a green line that contains a blue underlined substring and then returns to green.
Color support is detected rather than assumed. The chalk.level property reports 0 for no color, 1 for 16 colors, 2 for 256 colors, and 3 for truecolor. The level is detected at import time, but you can override it, and the README warns that setting it applies globally to all Chalk consumers. For reusable modules the documented approach is a separate instance:
import {Chalk} from 'chalk';
const customChalk = new Chalk({level: 0});Both the level option and the level property throw for anything that is not an integer from 0 to 3. Omit the option, or pass undefined, to keep detection. Detection can also be forced from outside the process: --color and --no-color flags, or the FORCE_COLOR environment variable, where FORCE_COLOR=1, 2, or 3 sets the level directly and FORCE_COLOR=0 disables color. The README notes that a numeric FORCE_COLOR overrides detection and the terminal cannot raise it, while FORCE_COLOR=true only enables color and leaves the level to be detected. Explicit --color=256 and --color=16m take precedence over a non-zero numeric FORCE_COLOR. There is a separate chalkStderr instance configured against stderr rather than stdout, which matters when warnings and errors go to a different stream than normal output.
Installing Chalk and styling your first line
The README gives one install command. It does not document a CDN build, a browser script tag, or a global install, so npm is the path it presents.
npm install chalkThe package is ESM. The package.json sets type to module and exposes source/index.js as the default export, with source/index.d.ts for types. The README states plainly that Chalk 5 is ESM and that if you want to use Chalk with TypeScript or a build tool, you will probably want Chalk 4 for now. That warning predates version 6, and the engines field now reads node >=22, so the practical first step is confirming your runtime.
A first real use is a single styled line:
import chalk from 'chalk';
console.log(chalk.blue('Hello world!'));Run that in a terminal and you should see the text in blue. Pipe the same script to a file or run it where color is disabled and Chalk should emit the plain string, because the level is detected rather than hardcoded. If you need to confirm what the process decided, read chalk.level. The README also shows console.log string substitution working alongside styled strings, so chalk.green('Hello %s') with a name argument prints the substituted value inside the green escape sequence.
Where Chalk 6.0.0 will not fit
The engines field requires Node.js 22 or newer, and the package is ESM only. If your project is on Node.js 18 or 20, or if it uses CommonJS require() without a build or interop step, this version is the wrong tool and the README points at Chalk 4 for TypeScript and build-tool users. That is a real constraint, not a documentation gap: the exports map has a single default entry pointing at source/index.js, with no require condition.
There is a second, subtler failure mode around global state. The README says the level property applies globally to all Chalk consumers and that you should only set it in your own code. A library that sets chalk.level to force color will change behavior for every other module in the process, including the host application. The documented escape hatch is instantiating new Chalk({level: ...}), which is easy to miss if you skim the API.
Style support is also uneven at the terminal level, and the README is honest about it. It marks italic, underline, strikethrough, and the overline and double, curly, dotted, and dashed underline variants as not widely supported. Choosing any of those means the visual result depends on the emulator, not on Chalk. Finally, if all you need is to strip escape codes from a string, Chalk is the wrong dependency: the topics list points at strip-ansi for that job, and Chalk does not expose a stripping API in the documentation here.
Chalk versus yoctocolors and the vendored dependency question
The README links to yoctocolors as a smaller alternative and answers its own question about why not to switch to a smaller coloring package. The difference in approach is scope. Chalk exposes a broad style set: modifiers such as bold, dim, inverse, hidden, and visible, the named foreground and background colors, RGB and hex truecolor, underline colors, and the array exports modifierNames, foregroundColorNames, backgroundColorNames, underlineColorNames, and colorNames for validating style strings when you wrap the library. It also ships a separate stderr instance and a level option on a fresh instance. A smaller alternative trades that surface for less code.
The dependency story is more interesting than the headline. Chalk's package.json declares no runtime dependencies, but it vendors ansi-styles and supports-color into source/vendor and wires them through the #ansi-styles and #supports-color import map, with a browser variant of supports-color selected for non-Node conditions. The test script excludes source/vendor from coverage, and the xo lint config ignores it. So "no dependencies" means no install-time dependency tree, not no borrowed code. That is a reasonable trade for keeping the install footprint flat, and it also means the vendored code is maintained in this repository rather than resolved from npm.
Maintenance, release cadence and the MIT licence
The repository is not archived, and the last push was on 2026-09-18. The release history shows v6.0.0 on 2026-07-26, v5.6.2 on 2025-09-08, and v5.6.0 on 2025-08-17. The v5 line carried patch releases roughly a year before the major bump, and v6.0.0 is the current major, which means the upgrade cost is concentrated in the runtime requirement and module format rather than in API churn. The README describes the project as clean and focused, and the package.json files field ships only the source directory, so the published artifact is small and there is no build step for consumers.
Chalk is MIT licensed. In practice that permits use, modification, and redistribution in both open source and commercial projects, provided the copyright notice and permission notice are retained. This is a description of the licence text, not legal advice; if your organization has an approval process for third-party code, route it there. Note that the vendored ansi-styles and supports-color code lives inside the source directory that gets published, so any licence review should cover the vendored files as well as the top-level license file.
Upgrade cost is the thing to budget for. Moving from Chalk 4 to 5 or 6 is an ESM migration, and moving to 6 adds the Node.js 22 floor. The test script runs xo, c8, ava, and a TypeScript check against source/index.d.ts, so type definitions ship with the package and should be checked after any major upgrade.
Editorial conclusion
Adopt Chalk if you maintain a Node.js 22+ CLI that needs composable ANSI styling with no dependencies and you want the color level handled for you. Do not adopt it if you are pinned to Node.js 18 or 20, or if you need CommonJS require() without a build step, since Chalk 5 and later are ESM only. Before upgrading to 6.0.0, verify your runtime satisfies the engines field (node >=22), confirm your bundler or TypeScript setup handles ESM, and check whether anything in your codebase mutates the global chalk.level, which the API says applies to all Chalk consumers.
Frequently asked questions
How do I install Chalk in Node.js?
Run npm install chalk. The README gives that as the single install step, and the package ships as ESM with type set to module, so your project needs to import it rather than require it.
How do I install Chalk?
The README documents npm install chalk and nothing else, so there is no separate global install or browser script tag described. After installing, import the default export and call a style, as in chalk.blue('Hello world!').
What Node.js version does Chalk 6.0.0 require?
The package.json engines field reads node >=22, and the package is ESM only. If you are on an older runtime or need CommonJS, the README points TypeScript and build-tool users at Chalk 4.
How do I disable colors in Chalk output?
Set FORCE_COLOR=0 to forcefully disable color, or use the --no-color flag. You can also create a separate instance with new Chalk({level: 0}), which the README recommends for reusable modules because the level property applies globally to all Chalk consumers.
Why does Chalk show color when output is piped to a file?
Chalk detects color support and normally disables color when the terminal does not support it, but FORCE_COLOR=1, 2, or 3 forces color on and sets the level directly. A numeric FORCE_COLOR overrides detection, so the terminal cannot raise it to a higher level.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/chalk-chalk)