All open source

colore-js

A zero-dependency color toolkit for conversion, manipulation, harmony generation, parsing, and contrast analysis.

For design systems and theming that need color to stay accurate across formats.

npm install colore-js
GitHubnpmDocumentation

Purpose

Colore treats a color as a value rather than a string: parse it from any supported format, convert it without losing the components, manipulate it predictably, generate a palette around it, and measure it for contrast. The full surface is one import with nothing underneath it.

Monochromatic and complement

The two simplest harmonies it generates: one hue stepped through lightness, and the same hue rotated 180°.

Monochromatic

Complement

What it does

  • Convert

    34 functions

    hex and hex-alpha, rgb and rgba, hsl and hsla, hsv, lab, lch, xyz, cmyk and named colors, all cross-converted.

  • Manipulate

    8 functions

    Lighten, darken, saturate, desaturate, invert, blend, enhance, and set alpha.

  • Generate

    7 functions

    Complementary, analogous, triadic, tetradic and monochromatic harmonies, plus interpolated scales and random colors.

  • Analyse

    12 functions

    Contrast ratio and relative luminance for accessibility work, plus ten format validators.

Engineering note

No dependencies, and around 10 KB gzipped. It also reads and writes CSS custom properties directly, so a palette computed at runtime can go straight into the page without a serialization step in between.