This is a
playground to test code. It runs a full
Node.js environment and already has all of
npm’s 400,000 packages pre-installed, including
ansi-256-colors with all
npm packages installed. Try it out:
This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.
256 ansi color codes for styling terminal output
You probably want the higher-level chalk module for styling your strings.
$ npm install --save ansi-256-colors
var colors = require('ansi-256-colors'); console.log(colors.fg.getRgb(2,3,4) + colors.bg.getRgb(4,4,4) + 'Hello world!' + colors.reset);
The module exposes a
bg object, and a
reset code. Both the foreground and background objects contain:
Returns the color code for the given red-green-blue value.
All 256 color codes.
The 8 base color codes, guaranteed to work on every system.
The 8 base bright/bold color codes, guaranteed to work on every system.
The 24 grayscales ranging from white to black.
The 216 varying color tints, where the order corresponds to the code-point 36*
r + 6*
Closes any previously opened color codes.