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.
Nothing published for this version
1. TERM=dumb now disables colors during auto-detection
TERM=dumb now disables colors during auto-detectionAnsis now treats TERM=dumb as no color before applying COLORTERM, CI detection, PM2, Next.js runtime detection, and platform-specific defaults, #49.
Before, COLORTERM=truecolor or other later auto-detection checks could still enable colors even when the environment reported TERM=dumb. This could produce visible ANSI escape codes in environments such as Emacs M-x compile.
COLORTERM remains a color capability hint. FORCE_COLOR keeps the highest priority and can still explicitly enable colors.
| Use case | v4.3.1 | v4.4.0 | Notes |
|---|---|---|---|
TERM=dumb |
✅ may allow colors * | ❌ no color | TERM=dumb now has higher priority in autoDetectLevel. |
TERM=dumb + COLORTERM=truecolor |
✅ allow colors | ❌ no color | COLORTERM no longer overrides TERM=dumb. |
TERM=dumb + CI |
✅ allow colors | ❌ no color | CI detection runs after TERM=dumb. |
TERM=dumb + PM2 |
✅ may allow colors * | ❌ no color | PM2 detection runs after TERM=dumb. |
TERM=dumb + Next.js runtime |
✅ may allow colors * | ❌ no color | Next.js detection runs after TERM=dumb. |
COLORTERM without TERM=dumb |
✅ allow colors | ✅ allow colors | Unchanged. |
CI without TERM=dumb |
✅ allow colors | ✅ allow colors | Unchanged. |
PM2 without TERM=dumb |
✅ allow colors | ✅ allow colors | Unchanged. |
Next.js without TERM=dumb |
✅ allow colors | ✅ allow colors | Unchanged. |
* - Depends on additional conditions.
TERM=dumb with inherited COLORTERM=truecolor.stdout.isTTY is not exposed.npm run color-checker to print the environment values used by color detection and visually inspect ANSI 16, ANSI 256, and Truecolor rendering.fix(color-support): treat TERM=dumb as no color before applying COLORTERM, #49.
COLORTERM is a color level hint.
When TERM=dumb, Ansis now disables ANSI color output even if color environment variables such as COLORTERM=truecolor were inherited from a parent process (e.g. in Emacs M-x compile).
FORCE_COLOR keeps the highest priority and can still explicitly enable colors.
Auto-detection behavior changes after the fix
| Use case | v4.3.1 | v4.4.0 | Notes |
|---|---|---|---|
TERM=dumb |
✅ may allow colors * | ❌ no color | TERM=dumb now has higher priority in autoDetectLevel. |
TERM=dumb + COLORTERM=truecolor |
✅ allow colors | ❌ no color | COLORTERM no longer overrides TERM=dumb. |
TERM=dumb + CI |
✅ allow colors | ❌ no color | CI detection runs after TERM=dumb. |
TERM=dumb + PM2 |
✅ may allow colors * | ❌ no color | PM2 detection runs after TERM=dumb. |
TERM=dumb + Next.js runtime |
✅ may allow colors * | ❌ no color | Next.js detection runs after TERM=dumb. |
COLORTERM without TERM=dumb |
✅ allow colors | ✅ allow colors | Unchanged. |
CI without TERM=dumb |
✅ allow colors | ✅ allow colors | Unchanged. |
PM2 without TERM=dumb |
✅ allow colors | ✅ allow colors | Unchanged. |
Next.js without TERM=dumb |
✅ allow colors | ✅ allow colors | Unchanged. |
* - Depends on additional conditions.
test(color-support): add regression coverage for TERM=dumb with inherited COLORTERM=truecolor
The tests also cover PM2 and Next.js edge behavior where stdout.isTTY is not exposed.
test: add a manual color support checker
Run npm run color-checker to print the environment values used by color detection and visually inspect ANSI 16, ANSI 256, and Truecolor rendering.
test(deno): run CI against Deno 2.3+ and the current LTS
Deno 2.0-2.2 are no longer tested in the CI matrix because they cannot use the same deno.lock v5 format as Deno 2.3+.
Runtime compatibility with Deno 2.0-2.2 remains supported.
Nothing published for this version
Nothing published for this version
1. reset no longer appends a closing sequence
reset no longer appends a closing sequenceImportant
reset is now a single SGR command, not a paired open/close style. ansis.reset(value) prepends \x1b[0m and no longer appends a closing reset. If your code or snapshot tests relied on the trailing \x1b[0m, update them or add the reset explicitly (see below).
Before, reset was treated like any other style with an open and a close code, so it wrapped the value on both sides. That produced extra reset sequences in chained, nested, template literal, and multiline compositions, and the output did not match what a single reset should do.
Before:
ansis.reset('foo');
// "\x1b[0mfoo\x1b[0m"Now:
ansis.reset('foo');
// "\x1b[0mfoo"If you need a trailing reset, add it explicitly:
ansis.reset`foo ${ansis.red('bar')} baz` + ansis.reset();
// "\x1b[0mfoo \x1b[31mbar\x1b[39m baz\x1b[0m"ansis.reset() without argument returns just the reset code \x1b[0m, which makes appending it easy.
strip() removes OSC 8 hyperlink sequencesstrip() did not clear the OSC 8 sequences produced by link().
It now removes them and returns plain text:
ansis.strip(ansis.link('https://example.com', 'text'));
// "text"Styles created on one Ansis instance could appear on another instance that was created with a different color level. That could give output rendered at the wrong color level.
Now, instances are isolated, so each one keeps its own styles and level.
import { Ansis } from 'ansis';
const noColor = new Ansis(0);
const color = new Ansis(1);
// Fixed: chained styles on `noColor` stay unstyled.
noColor.red.bold('foo');
// -> 'foo'
// Reference: a colored instance still renders the same chain with ANSI styles.
color.red.bold('foo');
// -> '\x1b[31m\x1b[1mfoo\x1b[22m\x1b[39m'.extend() no longer affects other instancesCalling .extend() on one instance could override styles on other instances that use a different color level.
Now, the .extend() method stays local to the instance on which it is called.
import { Ansis } from 'ansis';
const trueColor = new Ansis(3);
const noColor = new Ansis(0);
trueColor.extend({
pink: '#ff69b4',
});
// Fixed: `extend()` stays local to `trueColor`.
trueColor.red('foo');
// -> '\x1b[31mfoo\x1b[39m'
// Fixed: extending `trueColor` does not leak styles or color level into `noColor`.
noColor.red('foo');
// -> 'foo'fix: remove closing reset ANSI sequence
reset is now treated as a single SGR command, not as a paired style.
This means ansis.reset(value) prepends \x1b[0m and does not append a closing reset sequence.
Before:
ansis.reset('foo');
// "\x1b[0mfoo\x1b[0m"
Now:
ansis.reset('foo');
// "\x1b[0mfoo"
If a trailing reset is needed, add it explicitly:
ansis.reset`foo ${ansis.red('bar')} baz` + ansis.reset();
// "\x1b[0mfoo \x1b[31mbar\x1b[39m baz\x1b[0m"
The fix removes extra reset sequences in chained, nested, template literal, and multiline style compositions
where treating reset as a paired style gave wrong output.
fix: strip() now removes OSC 8 hyperlink sequences generated by link()
ansis.strip(ansis.link(url, text)) now returns plain text
fix: prevent silent style leakage between Ansis instances created with different color levels
fix: .extend() on one Ansis instance no longer overrides styles created on other instances with different color levels
refactor: micro-optimisations to reduce code size
Nothing published for this version
Added link(url, text?) for OSC 8 hyperlinks, supported by many terminal emulators , #44
link(url, text?) for OSC 8 hyperlinks, supported by many terminal emulators, #44globalThis object for controlled color auto-detection, #47
import { Ansis } from 'ansis';
const color = new Ansis({
process: {
env: { FORCE_COLOR: '1' },
argv: ['node', 'app.js'],
stdout: { isTTY: false },
platform: 'linux',
},
});
console.log(color.level); // 1Fixed the handling edge cases for using ENV variables and CLI flags, #46
| Fixed edge case | Old behavior (bug) | New behavior (correct) |
|---|---|---|
FORCE_COLOR=1, NO_COLOR=1 |
disable color | enable color (FORCE_COLOR takes precedence over NO_COLOR) |
NO_COLOR=1, --color |
disable color | enable color (CLI color flags take precedence over NO_COLOR) |
FORCE_COLOR=1, --no-color |
disable color | enable color (FORCE_COLOR has the highest priority) |
--no-color --color |
disable color | enable color (last flag wins) |
--color with no detected colors |
truecolor | 16 colors (auto-detect fallback uses the minimum color level, not truecolor) |
link(url, text?) for OSC 8 hyperlinks, supported by many terminal emulatorsglobalThis object for controlled color auto-detectionimport { Ansis } from 'ansis';
const color = new Ansis({
process: {
env: { FORCE_COLOR: '1' },
argv: ['node', 'app.js'],
stdout: { isTTY: false },
platform: 'linux',
},
});
console.log(color.level); // 1
| Fixed edge case | Old behavior (bug) | New behavior (correct) |
|---|---|---|
FORCE_COLOR=1, NO_COLOR=1 |
disable color | enable color (FORCE_COLOR takes precedence over NO_COLOR) |
NO_COLOR=1, --color |
disable color | enable color (CLI color flags take precedence over NO_COLOR) |
FORCE_COLOR=1, --no-color |
disable color | enable color (FORCE_COLOR has the highest priority) |
--no-color --color |
disable color | enable color (last flag wins) |
--color with no detected colors |
truecolor | 16 colors (auto-detect fallback uses the minimum color level, not truecolor) |
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Added support named truecolors via ansis.extend() for both foreground and background.
Added support named truecolors via ansis.extend() for both foreground and background.
Foreground methods are created from the provided color names, and matching background methods bg* are generated automatically.
Example:
import ansis from 'ansis';
import colorNames from 'css-color-names';
const color = ansis.extend(colorNames);
console.log(color.orange('Orange foreground'));
console.log(color.bgOrange('Orange background')); // auto-generated from "orange"Note
The css-color-names (~6 kB) package exports CSS color names with their hex values.
This release removes the last barrier for projects migrating from Chalk v4 that used named truecolors:
- chalk.keyword('orange')('text');
+ color.orange('text');
- chalk.bgKeyword('orange')('text');
+ color.bgOrange('text');Ansis provides this feature with a simpler, more intuitive API.
Important
Ansis automatically interpolates named truecolors to the highest available color level supported by the current environment.
So you can safely use named truecolors anywhere without worrying about compatibility.
ansis.extend().
Foreground methods are created from the provided color names, and matching background methods bg* are generated automatically.
Example:import ansis from 'ansis';
import colorNames from 'css-color-names';
const color = ansis.extend(colorNames);
console.log(color.orange('Orange foreground'));
console.log(color.bgOrange('Orange background')); // auto-generated from "orange"
This release removes the last barrier for projects migrating from Chalk v4 that used named truecolor, e.g.
chalk.keyword('orange')('text'). Ansis now provides this feature with a simpler, more intuitive API.Nothing published for this version
Nothing published for this version
Nothing published for this version
Added readonly level property to get the detected color support level:
Added readonly level property to get the detected color support level:
0 - no colors,1 - 16 colors,2 - 256 colors,3 - truecolor.Access to detected color level:
console.log('Detected color level: ', ansis.level);Nothing published for this version
> This is not a breaking change. Ansis gracefully interpolates higher color depths (truecolor and 256 colors)
Ansis v4 drops unused duplicate aliases and legacy baggage. This release brings a stable and more compact ANSI library. v4 is ~15.7% smaller than v3.17
Follow the migration guide to upgrade.
<a name="v4-breaking-changes"></a>
This version now supports Deno 2.0 and above.
strike alias for strikethrough styleThe legacy strike alias has been removed to clean up the API and stay consistent with ANSI style conventions.
strike style was rarely (if ever) used and added unnecessary redundancy.ansis.strike() was found in public GitHub repositories.strikethrough name exclusively.grey, bgGrey, blackBright and bgBlackBright - use the standard gray and bgGray instead.gray vs grey vs blackBrightAll these color names referred the same ANSI code. However, keeping many separate names for the same color is too much for a small library.
gray only, without aliases?ANSI codes for the gray color:
90 - officially "bright black" foreground (i.e., gray) in terminal specs.100 - officially "bright black" background (i.e., bgGray) in terminal specs.Ansis prefers the more intuitive and commonly used names: gray and bgGray.
gray, bgGray - Standard spelling, common used, and intuitivegrey, bgGrey - British spelling, uncommon, rarely used, and redundant aliases for gray and bgGrayblackBright, bgBlackBright - Spec-style names for "bright black", less intuitive, never used, awkward for practical use[!NOTE] Supporting both
grayandgrey(or even worse, verbose aliases likebgBlackBright) introduces unnecessary duplication.
Ansis v4 is focused on a clean, minimal API by intentionally avoiding redundant aliases.
The following legacy method aliases have been removed:
| ❌ Removed Method | ✅ Use Instead |
|---|---|
ansi256(code) |
fg(code) |
bgAnsi256(code) |
bg(code) |
These aliases were originally added for compatibility with Chalk. Starting with this release, Ansis focuses on a cleaner and compact API, free from duplicated methods and legacy layers.
fg() and bg() are better than ansi256() and bgAnsi256()Ansis has grown beyond being a Chalk-compatible alternative - it's now a modern and compact ANSI library with its own identity.
Clean API
ansis.fg(code) and ansis.bg(code) are shorter more elegant than ansis.ansi256(code) and ansis.bgAnsi256(code)fg and bg clearly describe their purpose: setting foreground and background colorsfg() and bg() are already being used in GitHub projectsAnsiColorsExtend type.This type was intended to support extended theme colors, but it was never used in other projects. If you relied on it in your own code (e.g. for typing custom styles), you can easily define it yourself.
extend() methodThe extend() method has been redesigned for better TypeScript support and flexibility.
extend<U extends string>(colors: Record<U, string>): asserts this is Ansis & Record<U, Ansis>;
void.import ansis from 'ansis';
ansis.extend({ pink: '#FF75D1' });
console.log(ansis.pink('foo'));
import { Ansis } from 'ansis';
const ansis = new Ansis();
ansis.extend({ pink: '#FF75D1' }); // TS2775: Assertions require every name in the call target to be declared with an explicit type annotation.
console.log(ansis.pink('Hello')); // TS2339: Property 'pink' does not exist
extend<U extends string>(colors: Record<U, string >): Ansis & Record<U, Ansis>;
Returns an extended instance with full type support.
✅ Works with both ansis and new Ansis():
import antis from 'ansis';
const colors = ansis.extend({ pink: '#FF75D1' });
console.log(colors.pink('foo'));
import { Ansis } from 'ansis';
const ansis = new Ansis().extend({ pink: '#FF75D1' });
console.log(ansis.pink('foo'));
TypeScript cannot widen the type of an existing variable when using asserts.
This means the old approach only worked for top-level constants like ansis, not new instances.
By returning the extended instance, the new approach enables full type inference in all scenarios.
Summary:
asserts version removedextend() now returns an instance with extended types<a name="v4-features"></a>
Ansis now treats tagged template literals the same way as normal strings, returning the same result as the standard function call.
Example with \n (newline, unescaped):
red('prev\nnext')
red`prev\nnext`
Output:
prev
next
Example with escaped backslash:
red('prev\\next')
red`prev\\next`
Output:
prev\next
Ansis automatically detects color support, but you can manually set the color level.
You can create a new instance of Ansis with the desired color level.
Disable colors:
import { Ansis } from 'ansis';
const ansis = new Ansis(0);
console.log(ansis.red`foo`); // Output: plain string, no ANSI codes
Use only basic 16 colors:
import { Ansis } from 'ansis';
const ansis = new Ansis(1);
console.log(ansis.hex('#FFAB40')`Orange`); // Output: fallback to yellowBright
Affects: In rare CI environments, output may fallback to 16 colors or black & white.
Ansis provides basic support for standard CI environments by checking the commonly used CI environment variable. In these environments, Ansis assumes support for at least 16 colors. If your code uses 256-color or truecolor, Ansis automatically fallback to 16 colors or to black and white if no color support is detected.
Ansis focuses on the most common scenarios, as specific CI environments are rarely used in practice. This approach keeps the package lightweight without including unnecessary detection logic.
GitHub Actions is still detected as supporting truecolor, as most Ansis users rely on GitHub CI.
In general, color output in CI environments is not critical and can gracefully fallback when needed.
The xterm-direct detection logic (introduced in v3.5.0) has been removed, as it's unnecessary for identifying truecolor-capable terminals.
[!NOTE]
No terminal emulator sets
TERM=xterm-directby default. Modern terminals, including KDE Konsole, typically useTERM=xterm-256coloralong withCOLORTERM=truecolorto indicate truecolor support.
Ansis now defaults uses 16 colors if it cannot detect support for 256 colors or truecolor.
[!NOTE]
This is not a breaking change. Ansis gracefully interpolates higher color depths (truecolor and 256 colors) down to 16 colors when using, e.g.,
fg(),hex()orrgb(). To explicitly enable truecolor, set the environment variableCOLORTERM=24bitorFORCE_COLOR=3.
<a name="migrating-to-v4"></a>
[!NOTE] There is extremely low likelihood that you'll need to migrate, as these changes are related to very very rare use cases. But to be sure, please check your code for these changes.
This version supports Deno 2.0 and newer.
strike with strikethrough- ansis.strike('text')
+ ansis.strikethrough('text')
grey and blackBright with gray- ansis.grey('text')
- ansis.blackBright('text')
+ ansis.gray('text')
bgGrey and bgBlackBright with bgGray- ansis.bgGrey('text')
- ansis.bgBlackBright('text')
+ ansis.bgGray('text')
ansi256() with fg()- ansis.ansi256(196)('Error')
+ ansis.fg(196)('Error')
bgAnsi256() with bg()- ansis.bgAnsi256(21)('Info')
+ ansis.bg(21)('Info')
extend() methodThe new extend() method now returns an extended instance instead of modifying the original instance in-place.
To migrate, assign the result of extend() to a new variable (avoid reassigning the original instance):
import ansis from 'ansis';
- ansis.extend({ pink: '#FF75D1' });
+ const colors = ansis.extend({ pink: '#FF75D1' });
- console.log(ansis.pink.bold('foo'));
+ console.log(colors.pink.bold('foo'));
Alternatively:
- import ansis from 'ansis';
+ import { Ansis } from 'ansis';
- ansis.extend({ pink: '#FF75D1' });
+ const ansis = new Ansis().extend({ pink: '#FF75D1' });
console.log(ansis.pink.bold('foo'));
AnsiColorsExtend type manuallyIf you previously imported the AnsiColorsExtend type, you’ll now need to define it manually as it has been removed from Ansis.
Below is how you can define and use it in your TypeScript code:
- import ansis, { AnsiColorsExtend } from 'ansis';
+ import ansis, { AnsiColors } from 'ansis';
+ type AnsiColorsExtend<T extends string> = AnsiColors | (T & Record<never, never>);
const myTheme = {
orange: '#FFAB40',
};
// Extend ansis with custom colors
const colors = ansis.extend(myTheme);
// Custom logger supporting both built-in and extended styles
const log = (style: AnsiColorsExtend<keyof typeof myTheme>, message: string) => {
console.log(colors[style](message));
}
log('orange', 'message'); // extended color
This change ensures compatibility with the latest version of Ansis, as the AnsiColorsExtend type is no longer included by default.
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
feat: drop support for Deno 1.x (EOL - 9 Oct 2024) and add support for Deno 2.0+, #37 Backported from 3.18.0-beta.0
Replace deprecated aliases with the preferred standard names:
Removed unused and rarely used aliases for gray and bgGray:
grey, bgGrey - British spelling, uncommon, redundant aliases for gray and bgGrayblackBright, bgBlackBright - Spec-style names for "bright black", less intuitive, rarely used, and awkward in practiceSupporting three separate names for the same color is too much and introduces ambiguity into the API.
Replace deprecated aliases with the preferred standard names:
- ansis.grey('text')
- ansis.blackBright('text')
+ ansis.gray('text')
- ansis.bgGrey('text')
- ansis.bgBlackBright('text')
+ ansis.bgGray('text')
The unused AnsiColorsExtend type has been removed.
The unused AnsiColorsExtend type has been removed.
This type was intended to support extended theme colors, but it was never used in other projects. If you relied on it in your own code (e.g. for typing custom styles), you can easily define it yourself.
If you previously used the AnsiColorsExtend type, you’ll now need to define a custom utility type.
Here's an example how to update your code:
- import ansis, { AnsiColorsExtend } from 'ansis';
+ import ansis, { AnsiColors } from 'ansis';
+ type AnsiColorsExtend<T extends string> = AnsiColors | (T & Record<never, never>);
const myTheme = {
orange: '#FFAB40',
};
// Extend ansis with custom colors
const colors = ansis.extend(myTheme);
// Custom logger supporting both built-in and extended styles
const log = (style: AnsiColorsExtend<keyof typeof myTheme>, message: string) => {
console.log(colors[style](message));
}
log('orange', 'message'); // extended color
This change ensures compatibility with the latest version of Ansis, where AnsiColorsExtend is no longer available.
The following legacy method aliases have been removed:
The following legacy method aliases have been removed:
| ❌ Removed Method | ✅ Use Instead |
|---|---|
ansi256(code) |
fg(code) |
bgAnsi256(code) |
bg(code) |
These aliases were originally added for compatibility with Chalk. Starting with this release, Ansis focuses on a cleaner and compact API, free from duplicated methods and legacy layers.
fg() and bg() are better than ansi256() and bgAnsi256()Ansis has grown beyond being a Chalk-compatible alternative - it's now a modern and compact ANSI library with its own identity.
Clear and expressive API
ansis.fg(code) and ansis.bg(code) are shorter more elegant than ansis.ansi256(code) and ansis.bgAnsi256(code)fg and bg clearly describe their purpose: setting foreground and background colorsfg() and bg() are already being used in GitHub projectsUpdating from a previous version is simple:
import ansis from 'ansis';
- ansis.ansi256(196)('Error')
+ ansis.fg(196)('Error')
- ansis.bgAnsi256(21)('Info')
+ ansis.bg(21)('Info')
Alternatively, to keep compatibility with existing code:
- import { ansi256, bgAnsi256 } from 'ansis';
+ import { fg as ansi256, bg as bgAnsi256 } from 'ansis';
ansi256(196)('Error')
bgAnsi256(21)('Info')
No other changes are required - everything else remains fully compatible.
feat: refactor .d.ts and reduce the package size
The extend() method has been redesigned for better TypeScript support and flexibility.
extend() methodThe extend() method has been redesigned for better TypeScript support and flexibility.
extend<U extends string>(colors: Record<U, string | P>): asserts this is Ansis & Record<U, Ansis>;
void.import ansis from 'ansis';
ansis.extend({ pink: '#FF75D1' });
console.log(ansis.pink('foo'));
import { Ansis } from 'ansis';
const ansis = new Ansis();
ansis.extend({ pink: '#FF75D1' });
console.log(ansis.pink('Hello')); // TS2339: Property 'pink' does not exist
extend<U extends string>(colors: Record<U, string | P>): Ansis & Record<U, Ansis>;
ansis and new Ansis():import ansis, { Ansis } from 'ansis';
const colors = ansis.extend({ pink: '#FF75D1' });
console.log(colors.pink('foo'));
const custom = new Ansis().extend({ apple: '#4FA83D' });
console.log(custom.apple('bar'));
TypeScript cannot widen the type of an existing variable when using asserts.
This means the old approach only worked for top-level constants like ansis, not new instances.
By returning the extended instance, the new approach enables full type inference in all scenarios.
Summary:
asserts version removedextend() now returns a new instance with extended typesThe new extend() method now returns an extended instance instead of modifying the original in-place.
To migrate, assign the result of extend() to a new variable (avoid reassigning the original instance):
import ansis from 'ansis';
- ansis.extend({ pink: '#FF75D1' });
+ const theme = ansis.extend({ pink: '#FF75D1' });
- console.log(ansis.pink('foo'));
+ console.log(theme.pink('foo'));
Or
import { Ansis } from 'ansis';
- ansis.extend({ pink: '#FF75D1' });
+ const ansis = new Ansis().extend({ pink: '#FF75D1' });
console.log(ansis.pink('foo'));
Ansis automatically detects color support, but you can manually set the color level.
You can create a new instance of Ansis with the desired color level.
Disable colors:
import { Ansis } from 'ansis';
const custom = new Ansis(0);
console.log(custom.red`foo`); // Output: plain string, no ANSI codes
Use only basic colors:
import { Ansis } from 'ansis';
const custom = new Ansis(1);
console.log(custom.hex('#FFAB40')`Orange`); // Output: fallback to yellowBright
Nothing published for this version
feat: reduce size of index.d.ts file
- feat: reduce the package size
Nothing published for this version
Nothing published for this version
Nothing published for this version
feat: slightly improve performance for hex function
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
The xterm-direct detection logic (introduced in v3.5.0) has been removed, as it's unnecessary for identifying truecolor-capable terminals.
xterm-direct terminfo check for truecolor support (not a breaking change)The xterm-direct detection logic (introduced in v3.5.0) has been removed, as it's unnecessary for identifying truecolor-capable terminals.
Note
No terminal emulator sets
TERM=xterm-directby default. Modern terminals, including KDE Konsole, typically useTERM=xterm-256coloralong withCOLORTERM=truecolorto indicate truecolor support.
Nothing published for this version
> This is not a breaking change. Ansis gracefully interpolates higher color depths (truecolor and 256 colors)
Ansis now defaults uses 16 colors if it cannot detect support for 256 colors or truecolor.
Note
This is not a breaking change. Ansis gracefully interpolates higher color depths (truecolor and 256 colors) down to 16 colors when using
fg(),hex()orrgb(). To explicitly enable truecolor, set the environment variableCOLORTERM=24bitorFORCE_COLOR=3.
The legacy strike alias has been removed to clean up the API and stay consistent with ANSI style conventions.
strike style (alias for strikethrough)The legacy strike alias has been removed to clean up the API and stay consistent with ANSI style conventions.
strike style was rarely (if ever) used and added unnecessary redundancy.ansis.strike() was found in public GitHub repositories.strikethrough name exclusively.If you're using strike style, replace it with strikethrough.
Ansis now treats tagged template literals the same way as normal strings, returning the same result as the standard function call.
Example with \n (newline, unescaped):
red('prev\nnext')
red`prev\nnext`
Output:
prev
next
Example with escaped backslash:
red('prev\\next')
red`prev\\next`
Output:
prev\next
Deprecated. ---
Deprecated.
Note The switch to Deno 2.0+ support is a breaking change and will be officially included in the next major release. For v3.x users, it's available as…
Note
The switch to Deno 2.0+ support is a breaking change and will be officially included in the next major release.
For v3.x users, it's available as an unofficial v3.18.0-beta.0 and will not be released as v3.18.0.
Added support for older typescript versions (< 5.6 ) to fix TS2526 error:
Added support for older typescript versions (< 5.6) to fix TS2526 error:
A 'this' type is available only in a non-static member of a class or interface.
Note
If you are already using TypeScript >= 5.6, this update is not required.
typescript < 5.6 to fix TS2526 error:A 'this' type is available only in a non-static member of a class or interface.
NOTE: If you are already using TypeScript >= 5.6, this update is not required.Reverted the full text of ISC license.
tsup bundler.chore: revert the full text of ISC license from https://opensource.org/license/isc-license-txt
Nothing published for this version
Nothing published for this version
refactor: micro optimisations for named exports to slight reduce the package size by ~40 bytes.
feat: reduce the package size by ~200 bytes.
tsup bundler.Your coding agent can read these notes before it upgrades. Set up the MCP server →