chroma.js
JavaScript library for color conversion, manipulation, and scale generation
Repository Health
Technical Analysis
chroma.js is a small library for all kinds of color operations in the browser and Node.js: converting between color spaces (RGB, HSL, LAB, LCH, HSV, and more), reading colors from CSS strings, named colors, or hex/temperature values, and generating smooth color scales and palettes for maps and charts. It bundles the classic ColorBrewer palettes and X11/CSS named colors out of the box, so data-visualization projects can pull in perceptually reasonable color ramps without hand-picking hex values.
The library exposes a chainable chroma() API for building up color transformations (darken, brighten, saturate, mix, blend) and a chroma.scale() API for interpolating between colors across a domain, commonly used to color choropleth maps, heatmaps, and data-driven charts.
What You Get
- Color parsing and conversion across RGB, HSL, HSV, LAB, LCH, CMYK, and named/hex/CSS color strings
- A chainable color-manipulation API (darken, brighten, saturate, desaturate, alpha, mix, blend)
- A
chroma.scale()API for building continuous or discretized color scales/gradients between multiple colors - Built-in ColorBrewer palettes and X11/CSS named colors ready to use as scale inputs
- Color-distance and contrast utilities for accessibility and perceptual-difference checks
Common Use Cases
- Coloring choropleth maps and heatmaps by interpolating a value across a color scale
- Generating data-visualization color palettes (sequential, diverging, categorical) from ColorBrewer presets
- Programmatically lightening, darkening, or blending brand colors for hover/active UI states
- Converting user-supplied or design-token colors between formats (hex, RGB, HSL) for theming systems
Under The Hood
Architecture: The chroma() factory in Color.js normalizes any input format through src/io/input.js, which dispatches to per-space parsers under src/io/ (hex, css, named, cmyk, hsl, hsv, lab, lch, gl, num), converting everything to an internal RGB representation that manipulation methods (darken, saturate, mix) and src/generator/src/interpolator scale logic operate on before re-serializing back out through the same io modules on demand. Tech Stack: Written in modern JavaScript (ESM, ships both index.js ESM and dist/chroma.cjs CJS/UMD builds via Rollup), with a handful of legacy .coffee files still present in the io layer (delta-e, distance) alongside newer plain-JS modules, built and tested with pnpm and Vitest. Code Quality: A large test/ directory (50+ files) covers each color-space converter and the scale/interpolation logic individually, giving good regression coverage for a library where subtle color-math bugs are easy to introduce; the codebase shows its age in a mix of coding styles (CoffeeScript remnants alongside ES modules) reflecting over a decade of incremental maintenance. API Design: The chainable chroma(color).method().method() style and the single chroma.scale() entry point for gradients keep the common cases terse, though the breadth of supported color-space names and options makes the full API surface non-trivial to memorize without consulting docs.
Used by 25 apps in this directory
Amplication
Developer Tools · AI Code Assistants · Automation
Create production-ready backend services with your organization's standards baked in — generating NestJS, Prisma, and GraphQL code that you own and control.
Anarlog
Note Taking · AI Assistants · Productivity
Anarlog is an open-source, local-first AI meeting notetaker that records, transcribes, and summarizes meetings entirely on your device — no cloud lock-in, no mandatory account, and every note saved as a plain markdown file you own forever.
Coder
Devops · Developer Tools · Code Editors
Self-hosted cloud development environments and AI coding agents — defined in Terraform, connected via WireGuard, automatically shut down when idle.
DevTools-X
Developer Tools
41 offline-first developer utilities in a single 10MB cross-platform desktop app — no Electron, no cloud, no compromise.
Directus
CMS · Low Code Platforms
Connect any SQL database and get instant REST and GraphQL APIs, a visual management Studio, and a native MCP server for AI agents — free for most organizations.
evidence
Analytics · Data Engineering
Turn SQL queries and markdown files into polished, interactive data apps and business intelligence reports — no drag-and-drop, no GUI, just code.
GB Studio
Developer Tools · Game Development · Design Tools
Drag-and-drop retro Game Boy game creator that compiles real ROMs — no coding required.
Hexabot
AI Development · Automation
Build and run agentic workflows across channels with YAML, tools, and RAG
Hi.Events
Ecommerce · Scheduling
Self-hosted event ticketing platform that keeps your attendee data, brand, and revenue completely under your control.