node package manager
Love JavaScript? Your insights can make it even better. Take the 2017 JavaScript Ecosystem Survey »



Build Status Dependency Status NPM version

Minimal semantic output styler API with default implementations.

A pluggable output styler/coloriser interface to embed in (development) tools and reporters. Offers a standard interface for customisable styled text output. The minimalistic API allows for overwrites to suit any environment.

Intend as companion to miniwrite (et al).


Main usage:

// standard console colors 
var ms = ministyle.ansi();
// semantic stylers (and color conventions) 
var str = ms.muted('ignorable grey');
var str = ms.plain('plain main');
var str = ms.accent('flashy cyan');
var str = ms.signal('bright magenta');
var str = ms.success('good green');
var str = ms.warning('annoying yellow');
var str = ms.error('bad red');
// usage 
console.log('this is ' + ms.success('very amaze'));

Bundled implementations:

// default 
var ms = ministyle.base();
// return as-is 
var ms = ministyle.plain();
// ansi terminal codes 
var ms = ministyle.ansi();
// html spans with default colors 
var ms = ministyle.html();
// html spans with css class 
var ms = ministyle.css();
// colors.js getters 
var ms = ministyle.colorjs();
// grunt v0.4.x 
var ms = ministyle.grunt();
// blank chars 
var ms = ministyle.empty();
// dev style wraps with [style:names]) 
var ms =;

Advanced sub types

Apply each style in-order

// standard methods will pass the value though each sub-style and return the result 
var ms = ministyle.stack(styles);
ms.enabled = true;
ms.stack = [];

Peek and update string:

// standard methods pass value through callback 
var ms = ministyle.peek(callback, main, alt?);
ms.enabled = true;
ms.callback = function(str, type, main, alt)//return new string, or false to send input to alt = otherStyleA;
ms.alt = otherStyleB;

Toggle to alternative:

// standard methods will use main if enabled, otherwise alt 
var ms = ministyle.toggle(main, alt?);
ms.main = otherStyleA;
ms.alt = otherStyleB;
ms.enabled = true;
// hacky = otherStyleC; 

Build your own

var obj = {
    plain: function (str) {
        return str;
    success: function (str) {
        return str;
    accent: function (str) {
        return str;
    signal: function (str) {
        return str;
    warning: function (str) {
        return str;
    error: function (str) {
        return str;
    muted: function (str) {
        return str;


Make it bigger:

var ms = ministyle.plain();
ms.error = ms.success = function(str) {
    return str.toUpperCase();

Safe html:

var ms = ministyle.peek(ministyle.escapeHTML, ministyle.css());


$ npm install ministyle --save


  1. Code/style generator to replicate style-type logic (needs to be efficient though).


  • 0.1.4 - Update to fix npm's README
  • 0.1.2 - Added signal colour, enabled strict mode, split in internal modules
  • 0.1.0 - Added tests, publishing to npm.
  • 0.0.1 - Extracted styling from miniwrite.


Install development dependencies in your git checkout:

$ npm install

Build and run tests:

$ grunt

See the Gruntfile.js for additional commands.


In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Note: this is an opinionated module: please create a ticket to discuss any big ideas. Pull requests for bug fixes are of course always welcome.


Copyright (c) 2013 Bart van der Schoor

Licensed under the MIT license.