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

colors-kit

v1.3.3

Published

color-kit is a zero-dependency module that can help you with a variety of color related tasks

Readme

Colors-kit is a zero-dependency module that can help you with a variety of color related tasks, such as:

  • Converting colors between different formats.
  • Creating color palettes.
  • Rating the contrast of two colors based on WCAG (Web Content Accessibility Guidelines).
  • Generating random colors.
  • Simulating different types of color blindness.
  • Extracting color palettes from an image.

Installation

npm install colors-kit

Usage

The following examples will give you a glance of what you can achieve with this library. To know more about the usage of the library check the documentation.

Validate

The Validate API helps validate colors. It ensures that colors have the correct value within the range of their current format. If a value is not within the correct range, the method will throw an error.

validateCmyk({ c: 69, m: 0, y: 42, k: 17 }) // Valid

validateCmyk({ c: 69, m: 0, y: 20 })
// Expected output: "Error: Expected property key (k) to be of type number, but got undefined."

validateHex("#45AA0F") // Valid

validateHex("45AAF4")
// Expected output: "Error: A hash symbol (#) must be present at the begining of the color."

Convert

The Convert API can handle five input color formats and convert them to seven output color formats.

hslToRgb({ h: 143, s: 62, l: 54 })
// Expected output: { r: 66, g: 211, b: 122 }

rgbToHex({ r: 66, g: 211, b: 122 })
// Expected output: '#42D37A'

Random

The Random API can create a random color in any of the seven formats the library handles.

getRandomLab()
// Expected output: { l: 45, a: -81, b: 67 }

getRandomHsv()
// Expected output: { h: 284, s: 100, v: 13 }

Color Blind

The Color Blind API can simulate different types of color blindness.

toDeuteranomaly('#42D37A')
// Expected output: '#5fad86'

toTritanopia('#f4fa53')
// Expected output: '#f49bb2'

toProtanopia({ r: 45, g: 75, b: 200 })
// Expected output: { r: 57, g: 58, b: 170 }

Palette

The Palette API can generate a color palettes of many different types.

makeAnalogousPalette('#3e7a72', 5)
// Expected output: ['#3e7a72', '#3e647a', '#3d457a', '#543e7a', '#723e7a']

makeMonochromaticPalette({ r: 2, g: 69, b: 0 }, 2)
// Expected output: [
//  { r: 2, g: 69, b: 0 },
//  { r: 22, g: 89, b: 12 }
// ]

From Image

The fromImage API work with the colors present on an image.

const imageUrl = 'https://e1.pxfuel.com/desktop-wallpaper/763/1015/desktop-wallpaper-6-blue-and-pink-landscape-nature-landscape-thumbnail.jpg'

async function extract() {
  const colors = await extractPalette(imageUrl, 5)

  return colors
}

extract()
// Expected output: ["#8c84ea', '#e7a6f9', '#3b7ee4', '#080419', '#3d2585']

Rate

The rate API rates colors based on certain properties and features. Like the Web Content Accessibility Guidelines (WCAG) criteria for contrast rate.

rateContrast(['#002719', '#c49c1a'])
// Expected output: {
//   contrastValue: 6.2,
//   AA: {
//     smallText: true,
//     largeText: true,
//     uiComponent: true
//   },
//   AAA: {
//     smallText: false,
//     largeText: true,
//     uiComponent: true
//   }
// }

Typescript

This library is build with vanilla typescript, so you will find the types you need to work on the types.d.ts file. See the documentation to know more about the interfaces and types used.