tinycolor2

Fast, dependency-free color parsing, conversion, and manipulation for JavaScript

Library
npm
v1.6.0
5,253 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
47 /100 Fair
Development Activity 0
Maintenance 20
Community 68
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
80 /100 Excellent
Architecture 70
Code Quality 75
Innovation 85
Learning Curve 90

tinycolor2 is a small, zero-dependency JavaScript library for parsing, converting, and manipulating colors. It accepts a wide range of loosely-formatted input — hex, RGB, RGBA, HSL, HSLA, HSV, HSVA, and CSS named colors — and exposes a chainable API for operations like lightening, darkening, desaturating, and spinning the hue, plus utilities for generating color combinations, checking WCAG readability, and picking the most readable color from a palette.

It has shipped essentially unchanged in API shape since 2011 and is widely used as a color-handling primitive underneath higher-level design-system and theming tools, thanks to its permissive parser and predictable, well-tested output formats.

What You Get

  • A permissive parser that accepts hex (3/6/8-digit), RGB(A), HSL(A), HSV(A), CSS named colors, and plain objects as input
  • Chainable manipulation methods — lighten, darken, brighten, desaturate, saturate, greyscale, spin, and setAlpha
  • Format conversion and string output for every supported color space (toHex, toRgbString, toHslString, toHsvString, toName, toFilter, and more)
  • Color combination generators — analogous, monochromatic, splitcomplement, triad, and tetrad palettes
  • WCAG readability utilities — readability(), isReadable(), and mostReadable() for accessible color-pair selection
  • Zero runtime dependencies and dual ESM/CJS builds published to npm

Common Use Cases

  • Normalizing arbitrary user- or API-supplied color strings into a single consistent format before storing or rendering them
  • Building theming or design-token systems that need to programmatically lighten/darken a base brand color for hover, active, or disabled states
  • Checking foreground/background color pairs for WCAG contrast compliance in accessibility tooling
  • Generating complementary or analogous color palettes for charts, avatars, or generative UI

Under The Hood

Architecture: The library is a single UMD module (tinycolor.js, ~1,200 lines after the Babel-transpiled build) wrapped around one constructor function, tinycolor(), that normalizes any accepted input through an internal inputToRGB → stringInputToObject pipeline into a canonical {r, g, b, a} representation stored on this. All public behavior — conversions, manipulations, combinations, readability checks — is implemented as prototype methods or static helpers layered on top of that single normalized state, so every method is a thin, composable wrapper around the same core RGB representation. The distributable files are generated from a single mod.js source via a Deno + Rollup + Babel build script (build.js) that emits matching UMD, CJS, and ESM bundles into npm/cjs and npm/esm.

Tech Stack: Runtime has zero dependencies — the entire library is dependency-free hand-written JavaScript. The build toolchain (Deno, Rollup, @rollup/plugin-babel, Terser) is dev-only and used solely to produce the UMD/CJS/ESM artifacts and a minified CDN bundle; it does not affect consumers. Package metadata (npm/package.json) declares module/main/browser/exports fields for correct resolution under both require and import.

Code Quality: test.js (2,174 lines) exercises parsing, every conversion method, every manipulation method, combination generators, and the readability utilities with concrete input/output assertions run via Deno’s test runner across both the CJS and ESM builds, so the two bundles are verified to behave identically. There is no TypeScript in the source itself (types are maintained separately via DefinitelyTyped), and there is no runtime input validation beyond the isValid() flag the constructor sets when parsing fails, but the test coverage of the parsing surface is unusually thorough given the size of the library.

API Design: The API is deliberately minimal and forgiving: a single factory function accepts almost any reasonable color representation without requiring exact formatting (commas, percent signs, and parentheses are all optional), and every mutating method returns this for chaining, e.g. tinycolor("red").lighten().desaturate().toHexString(). Method names mirror the color spaces and operations they represent one-to-one, keeping the surface predictable for anyone already familiar with basic color theory, and the README documents every method with a runnable example.

Used by 19 apps in this directory

TypeScript
85%
GPL 3.0

Notesnook

File Storage · Note Taking · Security

14,822

End-to-end encrypted, open-source note-taking where your data stays yours — even from the server.

View details
91
Repo Health
84
Technical
60
Dependency
Built with
TypeScript 85%
JavaScript 12%
Updated 5 days ago
Clojure
73%
MPL 2.0

Penpot

Design Tools

61,563

Open-source design platform with GPU-accelerated canvas, native design tokens, and MCP-powered AI workflows for teams that ship fast.

View details
91
Repo Health
83
Technical
72
Dependency
Built with
Clojure 73%
Updated 6 days ago
TypeScript
90%
MIT

Plasmic

CMS · Design Tools · Low Code Platforms

7,125

The open-source visual builder that lets teams design React apps and websites with drag-and-drop while integrating seamlessly with your codebase.

View details
81
Repo Health
78
Technical
64
Dependency
Built with
TypeScript 90%
Updated 6 days ago
Go
90%
AGPL 3.0

Pyroscope

Developer Tools · Devops · Monitoring

11,703

An open-source, horizontally scalable continuous profiling platform that pinpoints CPU, memory, and I/O bottlenecks down to the exact line of code, built by Grafana Labs alongside Loki, Tempo, and Mimir.

View details
92
Repo Health
89
Technical
65
Dependency
Built with
Go 90%
Updated 5 days ago
Python
99%
Apache 2.0

Rasa Open Source

AI Assistants · AI Development · Voice AI

21,353

Rasa Open Source is a Python machine learning framework for building contextual, multi-turn chatbots and voice assistants that understand natural language and maintain conversation state.

View details
62
Repo Health
78
Technical
63
Dependency
Built with
Python 99%
Updated 3 months ago
Python
45%
Other

Redash

Analytics · Data Engineering

28,849

Redash lets anyone connect to 35+ SQL and NoSQL data sources, write a query in the browser, and turn the result into a shared dashboard — no separate BI suite required.

View details
91
Repo Health
74
Technical
61
Dependency
Built with
Python 45%
JavaScript 29%
TypeScript 19%
Updated 1 weeks ago
HTML
68%
AGPL 3.0

ToolJet

AI Agents · Low Code Platforms · No Code Platforms

41,123

Open-source AI-native platform to build and deploy internal tools, workflows, and AI agents with a visual drag-and-drop builder and 80+ data source integrations.

View details
94
Repo Health
81
Technical
63
Dependency
Built with
HTML 68%
JavaScript 20%
Updated 5 days ago
TypeScript
65%
Other

Typebot

AI Assistants · AI Development · Developer Tools

10,576

Build sophisticated chatbots visually, embed them anywhere without iframes, and own your data — fully self-hostable with a modular block system and 30+ integrations.

View details
94
Repo Health
82
Technical
64
Dependency
Built with
TypeScript 65%
MDX 34%
Updated 6 days ago
TypeScript
87%
Other

Webiny JS

Blogging · CMS · Ecommerce

8,047

Open-source, self-hosted CMS on AWS serverless — a TypeScript framework you extend with code, not a product you configure through a UI.

View details
90
Repo Health
86
Technical
61
Dependency
Built with
TypeScript 87%
JavaScript 12%
Updated 6 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers