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

td-colors-utils

v1.0.1

Published

A lightweight TypeScript color utility library for validating, converting and mapping named colors, hex, RGB and RGBA values.

Readme

[TusinskiDev] Colors Utils

td-colors-utils

A lightweight TypeScript utility library for working with colors in web and design systems.

This package provides fast validation, conversion, and mapping functions for named colors, hex, RGB, and RGBA formats. It is designed for frontend developers, design tool builders, theme engines, and any TypeScript project that needs reliable color utilities.

Features

  • Validate CSS color formats: named colors, hex, hexa, rgb, rgba
  • Convert between hex, hexa, rgb, rgba, and named CSS colors
  • Resolve color names from numeric values and vice versa
  • Support for short and long hex codes, plus alpha-enabled color values
  • TypeScript-first API with helpful export types

Installation

npm install td-colors-utils

Quick Start

import ColorUtils from 'td-colors-utils';

const {isHexColor, hexToRgb, nameToHex, rgbToName} = ColorUtils;

const isHex = isHexColor('#3498db');
const rgb = hexToRgb('#3498db');
const name = rgbToName('rgb(52, 152, 219)');
const hexFromName = nameToHex('dodgerblue');

Use Cases

1. Theme generation and design systems

  • Convert theme palette values between hex, rgba, and named colors
  • Normalize color input strings in theme configuration
  • Determine fallback names for generated colors

2. UI builders and component libraries

  • Validate developer-provided color values before rendering
  • Convert dynamic color values for CSS-in-JS output
  • Support user-entered color values in design tools

3. Color pickers and editors

  • Parse a color string and show equivalent outputs in multiple formats
  • Automatically suggest named colors when a matching value exists
  • Convert short hex (#abc) to full hex and RGBA transparently

4. Data visualization and charting

  • Map palette names to hex codes for chart styling
  • Validate exported color values before generating SVG/CANVAS styles
  • Convert between color formats required by different rendering libraries

5. Accessibility and contrast tooling

  • Normalize colors to compare contrast ratios consistently
  • Convert all values to RGBA for alpha-aware contrast calculations
  • Validate color inputs from external datasets

API Examples

Validation helpers

ColorUtils.isNamedColor('tomato');
ColorUtils.isHexColor('#ff6347');
ColorUtils.isHexaColor('#ff634780');
ColorUtils.isRgbColor('rgb(255, 99, 71)');
ColorUtils.isRgbaColor('rgba(255, 99, 71, 0.8)');

Conversion helpers

ColorUtils.hexToRgb('#ff6347');
ColorUtils.hexToRgba('#ff6347');
ColorUtils.hexToName('#ff6347');
ColorUtils.rgbToHex('rgb(255, 99, 71)');
ColorUtils.rgbToName('rgb(255, 99, 71)');
ColorUtils.nameToHex('tomato');
ColorUtils.nameToRgba('tomato');

Generic color normalization

const normalized = ColorUtils.toRgba('tomato');
const rgbaProp = ColorUtils.toRgbaProp('#ff6347');
const colorInfo = ColorUtils.colorPropByHex('#ff6347');

TypeScript Support

The package exports useful types for strong color handling:

  • Color
  • Hex
  • Rgb
  • Rgba
  • RgbArray
  • RgbaArray

License

MIT