ansis
4.5.0 · 1 Nov 2026ISC56.7M / weekRepositoryHomepagenpmAtom feed
Where each line stands
Plan an upgradeLatest releases
All 62 releases- 4.x · latest line
4.5.0
1 Nov 2026color-support: prevent colors in piped or redirected output when
COLORTERMis set, #54color-support: detect the color level for
FORCE_COLOR=trueand--colorin non-TTY output
Bug Fixes
color-support: prevent colors in piped or redirected output when
COLORTERMis set, #54color-support: detect the color level for
FORCE_COLOR=trueand--colorin non-TTY output
Behavior
Colors are enabled only for a TTY, CI, and the PM2 and Next.js runtimes. Output to a pipe or a file has no colors, even when
COLORTERMis set.COLORTERMsets only the color level.FORCE_COLOR=true,FORCE_COLOR=and--colorin non-TTY output now detect the level from the environment (COLORTERM,TERM, Windows) instead of always using 16 colors.Upgrade note
If your tests relied on
COLORTERMto get colors, setFORCE_COLORinstead, for exampleFORCE_COLOR=3 npm test. See Testing.4.4.0
13 Sep 2026Ansis now treats
TERM=dumbas no color before applyingCOLORTERM, CI detection, PM2, Next.js runtime detection, and platform-specific defaults, #49.Bug fixes
1.
TERM=dumbnow disables colors during auto-detectionAnsis now treats
TERM=dumbas no color before applyingCOLORTERM, CI detection, PM2, Next.js runtime detection, and platform-specific defaults, #49.Before,
COLORTERM=truecoloror other later auto-detection checks could still enable colors even when the environment reportedTERM=dumb. This could produce visible ANSI escape codes in environments such as EmacsM-x compile.COLORTERMremains a color capability hint.FORCE_COLORkeeps 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=dumbnow has higher priority inautoDetectLevel.TERM=dumb+COLORTERM=truecolor✅ allow colors ❌ no color COLORTERMno longer overridesTERM=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.COLORTERMwithoutTERM=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.4.3.1
31 May 2026Before,
resetwas treated like any other style with anopenand aclosecode, 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 singleresetshould do.Bug fixes
1.
resetno longer appends a closing sequenceImportant
resetis now a single SGR command, not a paired open/close style.ansis.reset(value)prepends\x1b[0mand 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,
resetwas treated like any other style with anopenand aclosecode, 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 singleresetshould 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.2.
strip()removes OSC 8 hyperlink sequencesstrip()did not clear the OSC 8 sequences produced bylink().
It now removes them and returns plain text:ansis.strip(ansis.link('https://example.com', 'text')); // "text"3. No style leakage between instances with different color levels
Styles created on one
Ansisinstance 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'4.
.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'
Dependency tracking · free for 3 projects
Know when your own dependencies move
This page watches ansis. inlinr reads your package.json and keeps the same watch on every dependency you declare, then tells you only what needs you.
Advisories reach you
An email when a critical or high advisory affects a project, before the next install.
Upgrades checked first
Peer ranges, Node, ESM-only and types changes read before you bump.
Only what matters
Majors and breaking notes stay; patches and sibling bumps fold into one line.
Registry facts last checked 4 Nov 2026. Releases and advisories last read 4 Nov 2026.