
Mei Lin Chen
A hex code does not describe a colour. It describes a number, and the meaning of that number depends on a colour space the code itself does not name. It describes a number, and the meaning of that number depends on a colour space that the code itself does not name. That is the root of most mismatches. Two hex values converted through rgb and compared as strings will disagree, because the conversion rounds to eight bits per channel and the two paths round differently. Values equal before rounding are rarely equal after. HSL is where the surprise compounds. Hue, saturation and lightness describe a point in a space built for human perception, but the space is cylindrical and the colours of equal lightness are not equally bright, which is a well-known defect and the reason HSLuv exists. Using HSL to pick a text colour and a background produces pairs with wildly different contrast. Gamma is the part worth the effort. Screens apply a transfer curve so that a mid grey looks mid, and skipping that curve makes everything look washed out. Any conversion between an sRGB hex value and a linear-light working space has to account for it, and colour tools that ignore gamma produce subtly wrong results at every step. Alpha deserves its own note. An eight-digit hex value with an alpha channel and a separate opacity property are not interchangeable, and alpha applied to a colour with an existing background produces a blend against that background rather than a new colour. For contrast I use the WCAG ratio formula, which operates on relative luminance and gives the number accessibility decisions are based on. CMYK appears only in print contexts, where the conversion is approximate because it depends on the press.
About ToolSura
ToolSura offers 80+ free, privacy-first online tools that run 100% in your browser — no uploads, no logins. Learn more about our mission →