What it does
polychrome is a JavaScript library for parsing and manipulating colour strings. Its documented inputs are three- or six-digit hex, RGB and HSL forms, including alpha forms for RGB and HSL. Methods return CSS-compatible hex, RGB or HSL output. Its JavaScript source is MIT-licensed and open for modification and redistribution.
Create a colour object, apply adjustments, then choose an output method. For example, darkening and fading can be chained before requesting an RGB string; an alpha value produces the corresponding RGBA form.
Setting and adjusting have different meanings. setLightness(value) supplies an absolute lightness, while lighten(percentage) changes the existing colour. Omitted arguments also behave differently: an absolute setter makes no change, lightening defaults to 10%, and fading defaults to 50%.
The object exposes numerical channels for inspection. Hue rotation wraps around the colour wheel, while tint and shade mix the colour with white and black respectively.
Strengths
- Absolute setters and relative adjustments are separate methods.
- Chainable transformations finish in standard CSS string formats.
Watch out for
- Documented hex input accepts three or six digits.
Best for
- JavaScript interfaces deriving related CSS colours.
Sources
- polychrome - npm (Oct 28, 2026)
- GitHub - cdonohue/polychrome: 🎨 Easy color manipulation in ~2kb (gzipped) · GitHub (Oct 28, 2026)
- polychrome/LICENSE at master · cdonohue/polychrome · GitHub (Oct 28, 2026)
- polychrome/package.json at master · cdonohue/polychrome · GitHub (Oct 28, 2026)
