HEX vs RGB vs HSL: Which Color Format Should You Use?

Updated 2026-08-31 · 3 min read

The same color, three notations

#3B82F6, rgb(59 130 246) and hsl(217 91% 60%) all describe one blue. HEX and RGB describe how much red, green and blue light to mix; HSL describes hue, saturation and lightness the way a designer thinks.

When to use which

Why HSL wins for design systems

With HSL you generate a whole scale from one hue by changing lightness, which keeps a theme coherent and makes dark mode a predictable transformation instead of a fresh set of hand-picked hex codes.

Alpha and contrast

All three formats support transparency (#3B82F680, rgb(59 130 246 / 50%), hsl(217 91% 60% / 50%)). Whatever notation you choose, verify text contrast is at least 4.5:1 for body copy — a color that passes in light mode often fails in dark mode.

Converting between the formats

HEX and RGB are the same numbers in different clothing: each pair of hex digits is one channel from 0 to 255, so #3B82F6 is 3B = 59, 82 = 130, F6 = 246. The conversion is exact in both directions.

HSL is a geometric transform of the same RGB cube: hue is the angle around a colour wheel from 0 to 360, saturation the distance from grey, and lightness the position between black and white. Round-tripping RGB to HSL and back can shift a value by one unit through rounding, which is harmless visually but means you should keep one format as the source of truth in your design tokens.

Building a palette with HSL

The reason design systems reach for HSL is that a whole scale falls out of a single hue. Fix the hue, vary lightness in even steps, and pull saturation down slightly at the extremes so the darkest and lightest steps do not look neon:

Contrast and accessibility

WCAG requires 4.5:1 contrast for body text and 3:1 for large text and meaningful UI elements. Lightness in HSL is not the same as perceived brightness — pure yellow at 50% lightness is far brighter to the eye than pure blue at 50% — so never assume equal L values give equal contrast.

Check the actual ratio for each text-on-background pair you ship, and check it again in dark mode, where a colour that passed on white frequently fails on near-black.

Modern CSS colour: OKLCH and wide gamut

OKLCH describes colour in perceptually uniform terms, so a change of 0.05 lightness looks like the same step regardless of hue — exactly what HSL fails to do. It also reaches colours outside sRGB on displays that support P3, giving noticeably richer accents on modern screens.

Browser support is now broad enough to use OKLCH as the authoring format with a hex fallback for older targets. If you are starting a design system today, defining tokens in OKLCH and exporting hex for handoff is the most future-proof arrangement.

Alpha, blending and the print question

All three notations support an alpha channel, but transparency composites against whatever is behind it, so a 50%-alpha grey over a photograph has no fixed contrast ratio at all. For text backgrounds, prefer an opaque colour computed to look like the blend.

CMYK belongs to print and cannot be converted accurately without knowing the paper and ink profile. Send print suppliers a proper colour profile or a Pantone reference; a CMYK approximation generated from a screen colour will not match the printed result.

Convert between formats instantly

The Color Converter shows HEX, RGB, HSL and CMYK side by side from a picker or a pasted value. Building a background? Try the CSS Gradient Generator.

Try the Color Converter →Convert colors between HEX, RGB, HSL and CMYK formats. Live color picker with instant conversion. Free, no signup.

Frequently asked questions

Is there a quality difference between HEX and RGB?

No — both are 8 bits per channel and describe exactly the same colors.

What about OKLCH?

OKLCH is perceptually uniform, so equal lightness steps look equal. It is excellent for modern palettes where browser support allows.

Why does my hex colour look different on another screen?

Displays differ in gamut and calibration; wide-gamut screens render sRGB values more saturated unless colour management is applied.

What does the 8-digit hex form mean?

The last two digits are the alpha channel, from 00 (transparent) to FF (opaque). 80 is roughly 50%.

Should design tokens be HSL or OKLCH?

OKLCH if your browser targets allow it, because equal lightness steps look equal; otherwise HSL with a hex export.

More guides

How Many Words Is a 5-Minute Speech?A 5-minute speech is roughly 625–750 words at a normal speaking pace. See word counts for 1, 3, 5, 10 and 20-minute talks, plus how to check yours instantly.How to Validate JSON and Fix Common Syntax ErrorsLearn how to validate JSON and fix the most common errors: trailing commas, single quotes, unquoted keys, comments and unescaped characters — with examples.Base64 Is Not Encryption: What It Actually DoesBase64 is reversible encoding, not encryption. Learn what Base64 is for, when to use it, its 33% size cost, and safe alternatives for protecting data.How to Decode a JWT SafelyLearn what is inside a JSON Web Token, how to decode the header and payload, how to read exp and iat claims, and why decoding is not verification.