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

color-value-tools

v1.0.0

Published

A tiny utility library for parsing, converting, and manipulating color values across common formats (hex, RGB, HSL, HSV, Lab, CMYK) and CSS variables.

Readme

color-value-tools

A tiny utility library for parsing, converting, and manipulating color values across common formats (hex, RGB, HSL, HSV, Lab, CMYK) and CSS variables.

Installation

npm install color-value-tools

Usage

Example (ESM / TypeScript):

import { normalizeColor, mixColors } from 'color-value-tools';

console.log(normalizeColor('#3498db'));
// { type: 'hex', hex: '#3498db', r: 52, g: 152, b: 219, ... }

console.log(mixColors('#ff0000', '#0000ff', 0.5));
// '#800080'

Example (CommonJS / Node):

const { normalizeColor, mixColors } = require('color-value-tools');
console.log(normalizeColor('rgba(255,0,0,0.5)'));

API & Options

  • isCssVariable: Check if a string is a CSS variable (e.g. var(--main)).
  • isHexColor: Detect hex color strings (3- or 6-digit, with or without #).
  • isRgbColor: Detect rgb() / rgba() color strings.
  • isHslColor: Detect hsl() / hsla() color strings.
  • getColorType: Returns the color type: hex, css-var, rgb, hsl, named, or unknown.
  • extractCssVariableName: Extracts the CSS variable name from var(--name).
  • normalizeHex: Normalizes and validates hex strings, returns a 6-digit lowercase hex (fallback #f5e477).
  • hexToRgb: Convert a hex color to an [r, g, b] tuple.
  • hexToRgba: Convert a hex color to an rgba(...) string with opacity.
  • hexToHsl: Convert a hex color to an [h, s, l] tuple.
  • hslToHex: Convert HSL values to a hex color string.
  • adjustHexBrightness: Lighten or darken a hex color by a percentage offset.
  • rotateHue: Rotate the hue of a hex color by degrees.
  • rgbToHex / rgbaToHex: Convert RGB(A) channels to #rrggbb / #rrggbbaa.
  • rgbToRgbaString / rgbaStringToRgba: Build and parse rgba(...) / rgb(...) strings.
  • rgbToHsl / hslToRgb: RGB ↔ HSL conversions.
  • rgbToHsv / hsvToRgb: RGB ↔ HSV conversions.
  • hexToHsv / hsvToHex: Hex ↔ HSV helpers.
  • hex8ToRgba / rgbaToHex8: Parse and build 8-digit hex with alpha.
  • normalizeColor: Universal parser/normalizer returning { type, hex?, r?, g?, b?, a?, h?, s?, l?, v? }.
  • mixColors: Linear interpolation between two colors (supports rgb or hsl mixing, returns hex/rgb/rgba/hsl).
  • relativeLuminance / contrastRatio: WCAG relative luminance and contrast ratio.
  • isDark / isLight: Quick luminance-based checks.
  • rgbToCmyk / cmykToRgb: CMYK conversions for print scenarios.
  • rgbToLab / labToRgb / rgbToLch / lchToRgb: Perceptual color space conversions (Lab / LCH) for advanced operations.

Author

Danil Lisin Vladimirovich aka Macrulez

GitHub: macrulezru

Website: macrulez.ru

License

MIT