color-space

Open collection of color spaces.
- Verified formulas
- Conventional ranges
- Zero dependencies
- JS / WASM / GLSL / LUT / ICC.
Use
import space from 'color-space';
space.rgb.oklch(255, 128, 0); // → [0.732, 0.186, 53] — modern CSS
space.slog3.rec2020(0.5, 0.5, 0.5); // camera log → UHD wide gamut
space.rgb.xyz(300, -10, 0); // → [59.7, 30.6, 2.8] — out-of-range in, unclamped out
// batch
space.rgb.oklch([255, 128, 0, 0, 255, 128]); // [0.732, 0.186, 53, 0.875, 0.234, 151]
// meta
space.lab.range; // [[0, 100], [-125, 125], [-125, 125]]
Individual spaces:
import oklch from 'color-space/oklch.js';
oklch.rgb(0.65, 0.25, 180); // matches CSS oklch(0.65 0.25 180)
Imports
color-space– All 162 interconnected spaces · 55 kB gzipcolor-space/<name>.js– One standalone spacecolor-space/lite– 27-space working set · 9 kB gzipcolor-space/wasm– lite set as WASM · bare.wasmincludedcolor-space/gl– GLSL/WGSL shader sourcecolor-space/lut–.cubeLUTs for Resolve, Premiere, OBS, ffmpeg — verified vs ACEScolor-space/icc– Matrix + TRC or CLUT profilescolor-space/data.json– Channels, ranges, provenance, references, graph, gamutsnpx --yes --package color-space color-space-mcp– MCP agent tools:convert·space·spaces·cube
Spaces
Motivation
A complete collection of color spaces: one minimal API, verified formulas. While alternatives focus on digital color spaces, this project takes broader perspective, covering historical and cross-disciplinary spaces as well. Side effects: corrected papers, color education, test cases for JS→WASM compilers (porffor, jz).
It is not a color toolbox — parsing, interpolation, ΔE, gamut mapping, contrast, palettes, alpha stay out. Pantone, NCS, RAL Classic, and similar licensed swatch catalogs aren't open and stay out as well.
Credits
Thanks to the researchers, theorists, specifiers, implementors — and the libraries that informed this one.
| Library | Spaces | Ranges | Specialty | Backends | Speed (op/s) |
|---|---|---|---|---|---|
| color-space | 162 | Conventional | JS · WASM · GLSL/WGSL · LUT · ICC | 36.4 | |
| color-space/wasm | 27 | Conventional | — | WASM | 1.3–2.5× JS batches |
| culori | ~35 | 0–1 | JS | 16.1 | |
| colorjs.io | ~40 | 0–1 | some | JS | 0.7 |
| texel/color | ~16 | 0–1 | JS | 15.9 | |
| chroma-js | ~12 | mixed | JS | 3.4 | |
| d3-color | 6 | mixed | JS | 34.4 |
Full comparison · npm run benchmark