npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

coloration

v1.0.6

Published

A library for converting and managing different color formats (RGB,HEX,HSV,HSL,CMYK)

Readme

coloration

Is a relatively small JavaScript library for converting between different color formats while being as efficient and as small as possible.

Features

  1. Simple to use and learn.
  2. Small (2kb minified and gzipped).
  3. Works in both node and in the browser (using tools like webpack).
  4. Compatible with es3 supporting implementations.
  5. Supports converting between HSV, HSL, RGB, HEX, CMYK.

Installation

npm i coloration

in your code

const coloration = require('coloration');

Usage

const coloration = require('coloration');

coloration.rgb.hex( 255, 255, 255 );   // returns '#ffffff'
coloration.rgb.hsv( 0, 0, 0 );         // returns [ 0, 0, 0 ]
coloration.rgb.hsl( 128, 0, 128 );     // returns [ 0, 0, 50.19607843137255 ]
coloration.rgb.cmyk( 0, 44, 66 );      // returns [ 0, 1, 0, 0.4980392156862745 ]

API

coloration is just an object which reference other objects which contain the desired conversion functionality.

meaning that it is perfectly safe to do this

const { rgb } = coloration;

rgb.hex( 0, 0, 0 ); // returns '000000'.
Note : That being said it is totally okay to reference any object that contain conversion methods, however you shouldn't reference the methods inside that object themselves, why ? because that make the function lose it's this binding resulting in confusing and error prone behavior.

RGB

coloration.rgb.hex( red: number, green: number, blue: number ): string

Converts the given RGB values into a HEX string

coloration.rgb.hsv( red: number, green: number, blue: number ): number[]

Converts the given RGB values into HSV.

coloration.rgb.hsl( red: number, green: number, blue: number ): number[]

Converts the given RGB values into HSL.

coloration.rgb.cmyk( red: number, green: number, blue: number ): number[]

Converts the given RGB values into CMYK.

hex

coloration.hex.rgb( hexStr: string ): number[]

Converts the given HEX string into RGB.

coloration.hex.hsv( hexStr: string ): number[]

Converts the given HEX string into HSV.

coloration.hex.hsl( hexStr: string ): number[]

Converts the given HEX string into HSL.

coloration.hex.cmyk( hexStr: string ): number[]

Converts the given HEX string into CMYK.

HSV

coloration.hsv.rgb( hue: number, saturation: number, value: number ): number[]c

Converts the given HSV values into RGB.

coloration.hsv.hex( hue: number, saturation: number, value: number ): string

Converts the given HSV values into a HEX string.

coloration.hsv.hsl( hue: number, saturation: number, value: number ): number[]

Converts the given HSV values into HSL.

coloration.hsv.cmyk( hue: number, saturation: number, value: number ): number[]

Converts the given HSV values into cmyk.

HSL

coloration.hsl.rgb( hue: number, saturation: number, value: number ): number[]

Converts the given HSL values into RGB.

coloration.hsl.hex( hue: number, saturation: number, value: number ): string

Converts the given HSL values into a HEX string.

coloration.hsl.hsv( hue: number, saturation: number, value: number ): number[]

Converts the given HSL values into HSV.

coloration.hsl.cmyk( hue: number, saturation: number, value: number ): number[]

Converts the given HSL values into cmyk.

CMYK

coloration.cmyk.rgb( cyan: number, magenta: number, yellow: number, black: number ): number[]

Converts the given CMYK values into RGB

coloration.cmyk.hex( cyan: number, magenta: number, yellow: number, black: number ): string

Converts the given CMYK values into a HEX string

coloration.cmyk.hsv( cyan: number, magenta: number, yellow: number, black: number ): number[]

Converts the given CMYK values into HSV

coloration.cmyk.hsl( cyan: number, magenta: number, yellow: number, black: number ): number[]

Converts the given CMYK values into HSL

To do

  1. Implementing some sort of caching to make the functions run a bit faster
  2. Adding more utility functions

Known bugs and issues

Right now there aren't any bugs, however if you find any strange behavior please head to the github page and open up an issue in the issue page.

License

MIT