A developer grabs #1A73E8 from the style guide, pastes it into CSS, then needs the same value as rgba() for a transparent overlay. Eyeballing the conversion is how you end up with a button one shade off the nav bar. Converting HEX to RGB or HSL is pure arithmetic, but doing it by hand invites rounding mistakes — especially when you also need a WCAG contrast check.
Paste a colour in any notation to get all three formats, contrast ratios, and harmony palettes ready to copy into code.
HEX, RGB, and HSL — Three Notations for the Same Pixel
HEX is shorthand for RGB: #1A73E8 means R 26, G 115, B 232. HSL rewrites it as hue 217°, saturation 82%, lightness 51% — same pixel, different mental model. HEX is compact for design tokens. RGB is native to canvas APIs. HSL maps to how humans think: “make it lighter” means raise L, “mute it” means lower S.
The gotcha: HEX rounds to 8-bit integers (0–255). HSL-to-RGB math often produces fractional values that get floored, so a round trip can shift by ±1 per channel. Pick one canonical format for your tokens and derive the rest.
Why HSL Beats RGB for Generating Tints, Shades, and Palettes
Lightening in RGB means raising all three channels by an amount that depends on the hue — guesswork. In HSL you bump L from 50% to 70% and the tint is done; hue and saturation stay put. Building a five-step scale is a single loop over the lightness axis.
The limit is perceptual uniformity. HSL treats all hues as equally bright at L 50, but yellow looks far brighter than blue at the same L value. CSS’s oklch() fixes this with a perceptually uniform lightness channel — better for precision accessibility palettes.
WCAG Contrast Ratios: The Numbers Behind Accessible Text
The WCAG 2.1 guidelines require 4.5:1 for normal text and 3:1 for large text (18px bold / 24px regular). The ratio uses relative luminance — a weighted sum of linearised RGB, not raw 0–255 values. A pair that “looks fine” can fail because the eye compensates better than users with reduced vision.
Alpha complicates it. An rgba() overlay at 60% opacity over white produces a different effective colour than the same overlay over black. Test contrast with the composited colour, not the alpha value alone.
Harmony Rules: Complementary, Analogous, and Triadic in Practice
Complementary colours sit 180° apart — maximum contrast, good for CTAs. Analogous span 30° either side — cohesive, low contrast. Triadic places three hues 120° apart — vibrant but hard to balance without muting two of the three.
These rules assume sRGB. On a Display P3 monitor a saturated green clips when exported to HEX — the harmony breaks. Stick to sRGB for web unless you explicitly target wide-gamut via CSS color(display-p3 ...).
Quick Interpretation: What Your Converted Values Tell You
The output gives HEX, RGB, and HSL plus contrast ratios against white and black. If the white ratio falls below 4.5, the colour fails WCAG AA for text on light backgrounds. If both ratios are low, the colour sits in mid-lightness and needs a stronger pairing for readable text.
Fast Clarifications on Color Workflow Pitfalls
- sRGB gamut clipping. Wide-gamut displays show colours with no exact HEX equivalent. Exporting silently clips to the nearest sRGB point — check after conversion.
- Dark-mode inversion. Flipping lightness (L 80 → L 20) does not guarantee the same contrast ratio. Re-check every text/background pair after inverting.
- Alpha and contrast. Transparency changes the composited colour the user actually sees but does not appear in a raw contrast calculation. Test with the flattened value.
Slips that break design reviews: copying three-digit HEX shorthand (#FFF) into a six-digit field and getting #FFF000 instead of #FFFFFF, and assuming CSS named colours match the same HEX across all browsers.
Related tools: Image DPI Calculator when colour accuracy matters alongside print resolution, Password Entropy Estimator for credentials on shared design systems, Regex Tester for validating HEX patterns in code, and API Rate Limit Planner for colour-API endpoints serving palettes at scale.
Conversions assume sRGB and 8-bit-per-channel precision. Contrast ratios follow WCAG 2.1 relative-luminance formulas — they do not replace accessibility audits or testing on actual devices and assistive technologies.