ansis
Formatting text in terminal with ANSI colors & styles.
Last updated 2 years ago by webdiscus .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ npm install ansis 
SYNC missed versions from official npm registry.

ansis
ANSI Styling


node Test codecov node

Colorize terminal with ANSI colors & styles, smaller and faster alternative to Chalk.

Usage example

import ansis, { red, green, black, ansi256, hex } from 'ansis';

ansis.cyan('path/to/file')
green('Succeful!')
red`Error!`
black.bgYellow`Warning!`
ansi256(214)`Orange`
hex('#E0115F').bold.underline('Hello TrueColor!')

🚀 Install and Quick Start
📖 Read full docs on GitHub

🏆 Compare & Benchmark

See the features comparison and benchmarks of most popular terminal colors libraries:
ansis chalk kleur kolorist colors.js colorette picocolors ansi-colors cli-color colors-cli.

💡 Highlights

ANSI demo

Open in StackBlitz

  • Supports ESM, CommonJS, TypeScript, Bun, Deno, Next.JS
  • Standard API compatible with Chalk
  • Default and named import import ansis, { red, green, bold, underline } from 'ansis'
  • Chained syntax red.bold.underline('text')
  • Nested template strings red`RED text ${green`GREEN text`} RED text`
  • Base ANSI styles dim bold italic underline strikethrough
  • Base ANSI 16 colors red`Error!` redBright`Error!` bgRed`Error!` bgRedBright`Error!`
  • ANSI 256 colors fg(56)`violet` bg(208)`orange`
  • TrueColor (RGB, HEX) rgb(224, 17, 95)`Ruby`, hex('#96C')`Amethyst`
  • Fallback to supported color space: TrueColor → 256 colors → 16 colors → no colors
  • ANSI codes as open and close properties `Hello ${red.open}World${red.close}!`
  • Strip ANSI codes method ansis.strip()
  • Correct style break at the end of line when used \n in string
  • Detect color support using ansis.isSupported() method
  • Supports CLI NO_COLOR FORCE_COLOR --no-color --color
  • Doesn't extend String.prototype
  • Zero dependencies

License

ISC

Current Tags

  • 1.6.0-beta.0                                ...           beta (a year ago)
  • 3.3.2                                ...           latest (4 months ago)

43 Versions

  • 3.3.2                                ...           4 months ago
  • 3.3.1                                ...           4 months ago
  • 3.3.0                                ...           4 months ago
  • 3.2.1                                ...           4 months ago
  • 3.2.0                                ...           7 months ago
  • 3.1.1                                ...           7 months ago
  • 3.1.0                                ...           7 months ago
  • 3.0.3                                ...           7 months ago
  • 3.0.2                                ...           7 months ago
  • 3.0.1                                ...           7 months ago
  • 3.0.0                                ...           8 months ago
  • 2.3.0                                ...           9 months ago
  • 2.2.0                                ...           9 months ago
  • 2.1.0                                ...           10 months ago
  • 2.0.3                                ...           a year ago
  • 2.0.2                                ...           a year ago
  • 2.0.1                                ...           a year ago
  • 2.0.0                                ...           a year ago
  • 1.6.0-beta.0                                ...           a year ago
  • 1.5.6                                ...           a year ago
  • 1.5.5                                ...           2 years ago
  • 1.5.4                                ...           2 years ago
  • 1.5.3                                ...           2 years ago
  • 1.5.2                                ...           2 years ago
  • 1.5.1                                ...           2 years ago
  • 1.5.0 [deprecated]           ...           2 years ago
  • 1.5.0-alpha.0                                ...           2 years ago
  • 1.4.0                                ...           2 years ago
  • 1.3.6                                ...           3 years ago
  • 1.3.5 [deprecated]           ...           3 years ago
  • 1.3.4                                ...           3 years ago
  • 1.3.4-alpha.1 [deprecated]           ...           3 years ago
  • 1.3.4-alpha.0 [deprecated]           ...           3 years ago
  • 1.3.3                                ...           3 years ago
  • 1.3.2                                ...           3 years ago
  • 1.3.1                                ...           3 years ago
  • 1.3.0                                ...           3 years ago
  • 1.2.2                                ...           3 years ago
  • 1.2.1                                ...           3 years ago
  • 1.2.0                                ...           3 years ago
  • 1.1.1                                ...           3 years ago
  • 1.1.0                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE