tinycolor2 — Color parsing, manipulation, and conversion for JavaScript
- npm: 8.9M weekly downloads, 4,086 dependents
- GitHub: 5,231 stars, 102 open issues
- Last release: v1.6.0 (Feb 2023), last commit: Feb 2023
- Maintainer: Brian Grinstead (inactive 3+ years)
- Main fork @ctrl/tinycolor compromised in Shai-Hulud supply chain attack (Sept 2025, CISA alert)
- Abandoned: No commits or releases in 3+ years, 102 unresolved issues
- Supply chain risk: The primary TypeScript fork (@ctrl/tinycolor) was compromised in the Shai-Hulud worm attack — one of the worst npm supply chain incidents ever (500+ packages infected, credential theft, persistent GitHub Actions backdoors). CISA issued an advisory.
- No safe maintained drop-in: colord is also abandoned (2022). chroma-js and colorjs.io have completely different APIs. No migration path exists for 4,086 dependent packages.
- Missing modern features: No ESM support, no TypeScript types (uses DefinitelyTyped), no OKLCH/P3/modern color spaces
tincture — verified available on npm
- TypeScript-first with generated
.d.ts - Zero dependencies
- ESM + CJS dual package (exports map)
- Pure functions internally, OOP wrapper for API compatibility
src/
index.ts # Main entry, tincture() constructor
color.ts # TinctureColor class (API-compatible with tinycolor)
parse.ts # Input parsing (hex, rgb, hsl, hsv, named, ratio)
convert.ts # Color space conversions (RGB ↔ HSL ↔ HSV ↔ Hex)
modify.ts # Modification methods (lighten, darken, saturate, etc.)
combine.ts # Palette/combination methods (complement, analogous, etc.)
readability.ts # WCAG contrast ratio and accessibility
names.ts # CSS named colors lookup table
util.ts # Clamping, rounding, format helpers
compat/
tinycolor2.ts # Drop-in tinycolor2 compatibility layer
Construction:
tincture(input)— from string, object, or named colortincture.fromRatio({r, g, b})— from 0-1 ratio values
Properties:
isValid(),getFormat(),getOriginalInput()getAlpha(),setAlpha(value)getBrightness(),getLuminance()isLight(),isDark()
Conversion (14 methods):
toHex(),toHexString(),toHex8(),toHex8String()toRgb(),toRgbString(),toPercentageRgb(),toPercentageRgbString()toHsl(),toHslString(),toHsv(),toHsvString()toName(),toFilter()(IE gradient filter)toString(format)
Modification (8 methods):
lighten(amount),brighten(amount),darken(amount)saturate(amount),desaturate(amount)greyscale(),spin(amount),clone()
Combination (6 methods):
complement(),splitcomplement()analogous(results, slices),monochromatic(results)triad(),tetrad()
Static utilities (5 methods):
tincture.equals(color1, color2)tincture.mix(color1, color2, amount)tincture.random()tincture.readability(color1, color2)tincture.isReadable(color1, color2, options)tincture.mostReadable(baseColor, colorList, options)
tincture/compat/tinycolor2 exports a tinycolor function with identical behavior to tinycolor2, allowing zero-change migration:
// Before
const tinycolor = require('tinycolor2');
// After
const tinycolor = require('tincture/compat/tinycolor2');- TypeScript-first with full type inference
- ESM + CJS dual package
- OKLCH color space support (new)
- Modern CSS color function output (rgb(), hsl() without commas)
- Tree-shakeable when using individual functions
- No prototype pollution vectors
- Color class with internal RGBA representation
- Input parsing: hex (#RGB, #RRGGBB, #RRGGBBAA), rgb(), hsl(), hsv(), named colors
- Basic construction and validation (
isValid(),getFormat()) - Package setup: TypeScript, ESM+CJS build, test framework
- All 14 conversion methods (toHex, toRgb, toHsl, toHsv, etc.)
- Property methods (getBrightness, getLuminance, isLight, isDark)
- Alpha handling (getAlpha, setAlpha)
- toString() with format parameter
- All 8 modification methods (lighten, darken, saturate, etc.)
- All 6 combination/palette methods (complement, analogous, etc.)
- Static utilities (equals, mix, random)
- Readability/accessibility methods (WCAG contrast)
- tinycolor2 compatibility wrapper
- Test against tinycolor2's own test suite (port tests)
- Edge case testing (invalid inputs, boundary values, precision)
- Cross-browser compatibility verification
- API documentation with examples
- Migration guide from tinycolor2
- README with badges, installation, usage
- npm publish as
tincture - GitHub repo: agentine/tincture
tincturenpm package- Full tinycolor2 API compatibility
- Drop-in compat layer at
tincture/compat/tinycolor2 - TypeScript declarations
- Comprehensive test suite