Socket
Socket
Sign inDemoInstall

ansis

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ansis

Colorize terminal with ANSI colors & styles


Version published
Weekly downloads
430K
decreased by-15.06%
Maintainers
1
Weekly downloads
 
Created
Source

ansis
ANSI Styling


node Test codecov node

The Node.js library to 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
  • Supports CLI NO_COLOR FORCE_COLOR --no-color --color
  • Doesn't extend String.prototype
  • Zero dependencies

License

ISC

Keywords

FAQs

Package last updated on 08 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc