Chroma.js

Powerful JavaScript color manipulation library. Chroma.js handles color parsing (hex, RGB, HSL, HSV, LAB, LCH, OKLCH), conversion between color spaces, color mixing, brewer scales for data visualization, and perceptually uniform color interpolation. Used in data visualization (Observable, D3), design tools, and agent UIs that need sophisticated color manipulation.

Evaluated Mar 06, 2026 (0d ago) v2.x / 3.x
Homepage ↗ Repo ↗ Developer Tools color manipulation javascript palette visualization scales hex rgb lab oklch
⚙ Agent Friendliness
66
/ 100
Can an agent use this?
🔒 Security
97
/ 100
Is it safe for agents?
⚡ Reliability
86
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
85
Error Messages
72
Auth Simplicity
100
Rate Limits
100

🔒 Security

TLS Enforcement
100
Auth Strength
100
Scope Granularity
100
Dep. Hygiene
88
Secret Handling
95

Local color manipulation — no network calls, no user data. No security concerns beyond keeping dependencies updated.

⚡ Reliability

Uptime/SLA
100
Version Stability
85
Breaking Changes
80
Error Recovery
80
AF Security Reliability

Best When

Building data visualizations or UI themes in JavaScript that need perceptually correct color manipulation and pre-built ColorBrewer palettes.

Avoid When

You only need simple hex-to-RGB conversion — native CSS or simple regex is sufficient without a full library.

Use Cases

  • Generate perceptually uniform color scales for agent data visualizations and dashboards using chroma.scale() with ColorBrewer palettes
  • Convert between color spaces in agent UI themes — hex to RGB to HSL for programmatic color manipulation
  • Create accessible color palettes by checking contrast ratios and adjusting lightness in the LAB/OKLCH color space
  • Interpolate between colors for agent chart gradients using chroma's bezier interpolation for smooth perceptual transitions
  • Generate categorical color schemes for multi-series agent charts using ColorBrewer presets optimized for color-blind users

Not For

  • CSS preprocessing — use Sass/Less color functions for CSS build-time color manipulation; Chroma.js is for runtime JavaScript
  • Color picker UI components — use react-colorful or spectrum for color picker inputs; Chroma.js is for programmatic manipulation
  • Server-side performance-critical color processing at scale — Chroma.js is accurate but not the fastest; pure math implementations may be faster

Interface

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

No authentication — local color manipulation library.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

Chroma.js is open source and free.

Agent Metadata

Pagination
none
Idempotent
Full
Retry Guidance
Not documented

Known Gotchas

  • Chroma.js 3.x is ESM-only — require('chroma-js') fails in CJS; stay on 2.x for CommonJS or migrate to ESM
  • Color space conversions (e.g., lab to rgb) can produce out-of-gamut values — check that .rgb() values are in 0-255 range before use; clamp() is available
  • chroma.scale() domain defaults to [0,1] — set .domain([min, max]) explicitly when mapping data values to colors; wrong domain produces off-scale colors
  • ColorBrewer palettes are included in Chroma.js but are copyrighted — attribution required when using them in commercial products
  • OKLCH and OKLAB support was added in 2.x — older documentation and StackOverflow answers may use LAB where OKLCH would be more perceptually accurate
  • chroma() constructor silently creates invalid colors from unrecognized strings — always validate input or use try/catch around chroma(userInput)

Alternatives

Full Evaluation Report

Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for Chroma.js.

$99

Scores are editorial opinions as of 2026-03-06.

5215
Packages Evaluated
26151
Need Evaluation
173
Need Re-evaluation
Community Powered