NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
npm · #1446 most downloaded on npm
ANSI color lib
Last release 20 days ago
14 Sep 2026
Release timing varies
gaps range from 8 days to 5 months
Nearly every release is documented
notes for 59 of 59 stable releases
58 versions withdrawn
withdrawn after publishing
5 years old
128 releases · first in 2021
One column per quarter.
refactor: slight reduce the package size
feat: remove "main" from package.json, since Ansis is a dual package using "exports".\ Note:
feat: reduce the package size by ~100 bytes
Warning This is not a BREAKING CHANGE because it was never officially documented!
Added support for chromium-based browsers.
Now you can use truecolor in the consoles of Chrome, Edge, Opera, Brave, Vivaldi and other Chromium-based browsers.
Browsers that do not support ANSI codes will display black and white text.
Added support for \n as a newline in template literals, e.g.: green`Hello\nWorld` renders:
Hello
World
Function ansis.reset() returns the reset escape code \e[0m.
Enforce a specific color support by a FORCE_COLOR value:
Removed undocumented pointless dummy function ansis(any).
Warning
This is not a BREAKING CHANGE because it was never officially documented!
import ansis from 'ansis';
ansis('text'); // <= now will occur the ERROR TS2349: This expression is not callable.This warning applies only to projects where Chalk was replaced with Ansis and something like chalk('text') was used.
Just replace ansis('text') with 'text'.
The ansis('text') function was a dummy and did nothing except return the same input string.
engines to "node": ">=14").ansis.red('') => '', // returns empty string w/o escape codesfalse and NaN to a string.'' was returned for falsy values.0 , e.g. ansis.red(0), returning empty string '', now return colored value '0'feat: add support for \n as a newline in template literals, e.g.: `` greenHello\nWorld renders: Hello World ``
\n as a newline in template literals, e.g.: green`Hello\nWorld` renders:Hello
World
feat: add support for legacy Node.js v14 (in package.json for npm was changed the engines to "node": ">=14")
engines to "node": ">=14")feat: ansis.reset() returns the reset escape code \e[0m
ansis.reset() returns the reset escape code \e[0mfeat: revert handling of null and undefined values to empty string as before v3.7.0, #25
null and undefined values to empty string as before v3.7.0, #25refactor: optimize package size
feat: enforce a specific color support by a FORCE_COLOR value:
feat: enforce a specific color support by a FORCE_COLOR value:
fix: if the function argument is an empty string should be returned an empty string w/o escape codes:
ansis.red('') => '', // returns empty string w/o escape codes
refactor: optimize code by size
fix: cast falsy values false, null, undefined, NaN to a string. In previous versions, the empty string '' was returned for falsy values.
false, null, undefined, NaN to a string.
In previous versions, the empty string '' was returned for falsy values.0 , e.g. ansis.red(0), returning empty string '', now return colored value '0'> This is not a BREAKING CHANGE because it was never officially documented!
ansis(any)[!WARNING] This is not a BREAKING CHANGE because it was never officially documented!
import ansis from 'ansis'; ansis('text'); // <= now will occur the ERROR TS2349: This expression is not callable.This warning applies only to projects where Chalk was replaced with Ansis and something like
chalk('text')was used.Just replace
ansis('text')with'text'.The
ansis('text')function was a dummy and did nothing except return the same input string.
Optimised the npm package size from 10.3 kB to 7.0 kB.
10.3 kB to 7.0 kB.
Now, Ansis is the
smallestyet most powerful library withrich functionality. A slightly smaller ispicocolors(6.4 kB), but it offers onlybasic functionality.
xterm-direct terminal as supportingtruecolor.COLORTERM environment variable with the following values: truecolor, 24bit, ansi256, ansi (16 colors).TypeScript compiled with tsc:
import ansis from 'ansis' now works so well as import * as ansis from 'ansis'.tsc option module is node16.module is node16refactor: invisible code optimisation
refactor: optimise npm package to reduce size by 3 kB, from 10.3 kB to 7.3 kB
COLORTERM variable for values: truecolor, 24bit, ansi256, ansi (16 colors)xterm-direct terminal to detect the truecolorGPG_TTY introduced in 3.5.0-beta.0 version, because it make no sensetsc:
import ansis from 'ansis' now works so well as import * as ansis from 'ansis'refactor: optimise npm package to reduce the size
feat: detect xterm-direct terminal as supported the truecolor
xterm-direct terminal as supported the truecolorCOLORTERM variable for values: truecolor, 24bit, ansi256, ansi (16 colors)COLORTERM with examplesdocs: remove badges in readme for npm package to reduce package size
docs: fix badge urls in readme for npm package
refactor: optimise npm package to reduce the size by ~0.5 kB, from 8.0 kB to 7.5 kB
refactor: optimise npm package to reduce the size by ~1 kB, from 8.9 kB to 8.0 kB
feat: add support environment variable GPG_TTY to detect it as isTTY. NOTE: in release v3.5.1 was removed as needles.
GPG_TTY to detect it as isTTY.
NOTE: in release v3.5.1 was removed as needles.tsc:
import ansis from 'ansis' now works so well as import * as ansis from 'ansis'type with dynamic properties instead of the interfacetsc, swc and esbuild compilersCorrect detect TTY on Windows platform.
kolorist package.fix: url to GitHub in readme for npm package
refactor: invisible code optimisations
fix: correct detect TTY on Windows platform
kolorist packageImproved performance, e.g. using chained styles: 70.000.000 -> 80.000.000 ops/sec
index.d.ts to reduce the size by ~200 bytes.README for NPM package to reduce the size by ~1 KB.index.d.ts to reduce the size by ~200 bytes,Deleted old named import syntax DEPRECATED in v2.0.0 (2023-11-03) If you update the package from v1.x to v3.3.0 then check your code:\ ESM ```diff
old named import syntax DEPRECATED in v2.0.0 (2023-11-03)
If you update the package from v1.x to v3.3.0 then check your code:- import { red } from 'ansis/colors';
+ import { red } from 'ansis';
CJS- const { red } = require('ansis/colors');
+ const { red } = require('ansis');
pickages.json for NPMREADME for NPMold named import DEPRECATED in v2.0.0 (2023-11-03).
If you update the package from v1.x to v3.3.0 then check your code:- import { red } from 'ansis/colors';
+ import { red } from 'ansis';
CJS- const { red } = require('ansis/colors');
+ const { red } = require('ansis');
package.json for npm packageReduce unpacked size of NPM package by ~ 1 KB
Added ansis.isSupported() method to detect color support.
ansis.isSupported() method to detect color support.Added detection of color support when using PM2 process manager.
v3.0.1 - v3.1.1feat: add detection of color support when using PM2 process manager
chore: add rollup-plugin-cleanup to remove comments from d.ts file for dist, that save yet 3 KB
chore: create mini version of README for NPM to minify package size
chore: reduce code bundle size from 3.8 KB to 3.4 KB
<a id="v3-0-0" name="v3-0-0"></a>
Added detection of color spaces support: TrueColor, 256 colors, 16 colors, no color (black & white).
hex() function.In the new major version 3.x are removed unused styles and methods.
⚠️ Warning
Before update, please check your code whether is used deleted styles and methods.
Drop supports for Node <= 14. Minimal supported version is 15.0.0 (Released 2020-10-20).
In the theory the v3 can works with Node12, but we can't test it.
The not widely supported styles are deleted:
faint (alias for dim), replace in your code with dimdoubleUnderline, replace in your code with underlineframe, replace in your code with underlineencircle, replace in your code with underlineoverline, replace in your code with underlineThe methods are deleted:
ansi, replace in your code with ansi256 or fgbgAnsi, replace in your code with bgAnsi256 or bgThe clamp (0, 255) for the ANSI 256 codes and RGB values is removed, because is unused. You should self check the function arguments.
The affected functions:
ansi256 and fg (alias to ansi256) - expected a code in the range 0 - 255bgAnsi256 and bg (alias to bgAnsi256) - expected a code in the range0 - 255rgb - expected r, g, b values in the range 0 - 255bgRgb - expected r, g, b values in the range 0 - 255hex() functionIn the new major version 3.x are removed unused styles and methods.
⚠️ Warning
Before update, please check your code whether is used deleted styles and methods.
Drop supports for Node <= 14. Minimal supported version is 15.0.0 (Released 2020-10-20).
In the theory the v3 can works with Node12, but we can't test it.
v3.3.0)ESM
- import { red } from 'ansis/colors';
+ import { red } from 'ansis';
CJS
- const { red } = require('ansis/colors');
+ const { red } = require('ansis');
The not widely supported styles are deleted:
faint (alias for dim), replace in your code with dimdoubleUnderline, replace in your code with underlineframe, replace in your code with underlineencircle, replace in your code with underlineoverline, replace in your code with underlineThe methods are deleted:
ansi, replace in your code with fgbgAnsi, replace in your code with bgThe clamp (0, 255) for the ANSI 256 codes and RGB values is removed, because is unused. You should self check the function arguments.
The affected functions:
fg - expected a code in the range 0 - 255bg - expected a code in the range0 - 255rgb - expected r, g, b values in the range 0 - 255bgRgb - expected r, g, b values in the range 0 - 255Added detection of additional terminals, thanks @dse, colors.js:issue #42.
v2.0.1 - v2.3.0number.bgGrey and bgGray aliases for bgBlackBright.feat: add supports the argument as number
numbernpm run comparefeat: add bgGrey and bgGray aliases for bgBlackBright
bgGrey and bgGray aliases for bgBlackBrightfix(index.d.ts): use function overload to make the tagged template have the correct type, #16
fix: could not find a declaration file for module 'ansis'
fix: missing exports of ansis.strip() and ansis.export() functions (issue was introduced in v2.0.0)
The deprecated OLD named import from 'ansis/colors' still works, but using TypeScript can be occurred the error: ` TS2307: Cannot find module ansis/co…
edge runtime.ansis:import { red } from 'ansis';
For example:
NEW v2.x.ximport ansis, { red } from 'ansis'; // default and named import
ansis.red`error`;
red`error`;
OLD v1.5.ximport ansis from 'ansis'; // default import
import { red } from 'ansis/colors'; // named import
ansis.red`error`;
red`error`;
dist/ directory by 50%.The deprecated OLD named import from 'ansis/colors' still works, but using TypeScript can be occurred the error:
TS2307: Cannot find module ansis/colors ...
Solution: update your code, e.g.: import { red } from 'ansis/colors' --> import { red } from 'ansis'
import { red } from 'ansis/colors' is deprecated, use the NEW named import.ansi() function name is deprecated, use ansi256() or alias fg() instead.bgAnsi() function name is deprecated, use bgAnsi256() or alias bg() instead.edge runtimeansis:import { red } from 'ansis'.TypeScript and your IDE show the error: TS2307: Cannot find module ansis/colors,import { red } from 'ansis/colors' --> import { red } from 'ansis'.import { red } from 'ansis/colors' is deprecated, use the NEW named importansi use fgbgAnsi use bgfeat: add supports the Next.js edge runtime
edge runtimechore: add PULL_REQUEST_TEMPLATE.md
Added support for nested template literal syntax: ``js console.log(redred ${yellowyellow ${greengreen} yellow} red) ``
v1.3.0 - v1.5.5console.log(red`red ${yellow`yellow ${green`green`} yellow`} red`)
import { red, green, yellow } from 'ansis/colors';
console.log(red.bold.underline`text`);
import ansis from 'ansis';
ansis.extend({ orange: '#FFAB40' });
console.log(ansis.orange.bold('text'));
strip() method to remove all ANSI codes from stringgrey for gray.fg() for .ansi256() and .bg() for .bgAnsi256() methods4 KB.visible style with nested template stringsbgAnsi and fg methods by named exportFORCE_COLOR=0 to force disable colorsfix: visible style with nested template strings
fix: set correct aliases for bgAnsi and fg methods by named export
fix: regard the value of the environment variable FORCE_COLOR=0 to force disable colors
fix: add missing export for CJS mode in package.json
DEPRECATE v1.5.0, because missing exports main for CJS mode, fixed in v1.5.1
Nothing published for this version
feat: add method strip() to remove all ANSI codes from string
build: properly generated distribution package, bump to last stable version 1.3.6
DEPRECATED: this version is broken
feat: optimize distributed code size to smaller than 4 KB
4 KBNothing published for this version
Nothing published for this version
feat: add UK spelling alias grey for gray
grey for grayfeat: add bundle generation for ESM
Your coding agent can read these notes before it upgrades. Set up the MCP server →