What it does
Color.js is a JavaScript colour library for browser and Node projects. It handles colour spaces including sRGB, Display P3, Lab and OKLCH, with conversion, comparison and interpolation tools.
Install colorjs.io or import its hosted module. Create a Color object from a CSS string or a colour space and coordinates, then convert it to the space needed by the application.
The output controls select a CSS format such as RGB or hex. This is separate from changing the stored coordinates: conversion preserves out-of-range values, while string output normally maps them into a displayable range. Gamut is the range of colours a space can reproduce.
Call toGamut() when the coordinates themselves must fit that range. It modifies the object, so clone first if the original must remain available. The mapping method can also be chosen explicitly.
Color.js uses the MIT licence, which permits adaptation and redistribution with its notices retained.
Strengths
- Object-oriented and selective procedural imports suit different application structures.
Watch out for
- Gamut mapping can discard colour information and can modify the working object.
Best for
- Developers handling wide-gamut colours and CSS output
Sources
- Color.js overview and installation (Oct 27, 2026)
- Color.js output guide (Oct 27, 2026)
- Color.js gamut mapping (Oct 27, 2026)
- Color.js MIT licence (Oct 27, 2026)
