Skip to content
T

TinyColor-Go

A verified behavioral port of TinyColor to Go

Created on 3rd August 2026

•

T

TinyColor-Go

A verified behavioral port of TinyColor to Go

The problem TinyColor-Go solves

TinyColor is a widely used JavaScript library for parsing, converting, and manipulating colors. Go applications that need the same behavior would otherwise need to reimplement it independently or depend on a JavaScript runtime.

TinyColor-Go provides a native Go implementation of TinyColor behavior. Developers can parse CSS-style colors, convert between RGB, HSL, and HSV, generate palettes, modify colors, and calculate contrast/readability through a lightweight Go API and CLI.

The port is validated against the original JavaScript project: the original suite runs against Go with 45 tests passed, 0 failed, and 1 upstream-ignored test. We also publish fixed compatibility corpora, a 60-second differential fuzz log with over one million cases and zero divergences, benchmarks, source hashes, and documented design decisions.

Challenges we ran into

The difficult part was not implementing color math—it was preserving JavaScript behavior exactly.

TinyColor accepts permissive CSS-like input, applies JavaScript-style coercion and normalization, mutates some instance methods, and depends on precise rounding and floating-point behavior in readability calculations. Small differences in parsing, alpha handling, hue wrapping, or numeric precision created observable mismatches.

We solved this by treating the pinned upstream source as the specification. We added exact JSONL differential corpora, compared Go output with the JavaScript oracle, fixed mismatches at their shared causes, and retained every discovered edge case as a regression test.

A second challenge was proving that the untouched original suite genuinely exercised Go. We created a test-only bridge that keeps the original test file byte-identical while routing color operations to the native Go implementation. The result is 45 passed, 0 failed, and the same single upstream-ignored test as the JavaScript baseline.

Discussion

Builders also viewed

See more projects on Devfolio