Skip to content
100% in your browser. Nothing you paste is uploaded — all processing runs locally. Read more →

Hex vs RGB vs HSL vs OKLCH

On this page
  1. At a glance
  2. Same color, four ways
  3. Hex — the universal default
  4. RGB — channels, not perception
  5. HSL — hue, saturation, lightness
  6. OKLCH — perceptually uniform
  7. Decision flowchart
  8. Common color-system mistakes
    1. Building a palette in HSL
    2. Mixing color spaces in a single palette
    3. Using RGB component math for “lighter”
  9. Browser support (early 2026)
  10. Try the tools
  11. Related across the network

TL;DR. Use hex for color literals in CSS. Use HSL when generating palettes by varying lightness or saturation. Use OKLCH when you need perceptually uniform changes (the modern design-system default). RGB is rarely the best choice for human-edited code, but it’s universal in image-processing libraries.

At a glance

FormatReads “by channel”Reads “by perception”Good forUsed in
Hex (#2563eb)Yes (RGB encoded)NoCSS literals, compact storageEverywhere
RGB (rgb(37, 99, 235))YesNoImage processing, programmatic generationCSS, image libs
HSL (hsl(220, 83%, 53%))NoPartlyDesigning palettes, vary saturation/lightnessCSS, design tools
HSV/HSBNoPartlySame as HSL but different L mappingPhotoshop, GIMP
OKLCH (oklch(54% 0.21 263))NoYesPerceptually-uniform palettesCSS Color L4, modern design systems
LAB / OKLabNoYesImage processing, color scienceICC profiles, OKLab raw
CMYKYes (subtractive)NoPrintAdobe

Same color, four ways

Tailwind blue-600:

hex:   #2563eb
rgb:   rgb(37, 99, 235)
hsl:   hsl(220, 83%, 53%)
oklch: oklch(54% 0.21 263)

All four reference the same sRGB pixel value. The difference is what each makes easy to manipulate.

Hex — the universal default

The most common form. Compact, designer-recognized, supported everywhere.

Use when:

Don’t use when:

What is a hex color? →

RGB — channels, not perception

Fundamentally the same as hex but spelled out. rgb(37, 99, 235) and #2563eb describe the same color.

Use when:

Don’t use when:

The big problem with RGB for design: small changes don’t look like small changes. Increasing red by 20 in rgb(35, 99, 235) creates a big visual shift; the same numeric change in rgb(120, 99, 235) is much less noticeable. Color perception is non-linear in RGB space.

HSL — hue, saturation, lightness

A polar-coordinate parameterization of the RGB cube. The same colors, but addressed by:

hsl(0,   100%, 50%)   /* pure red */
hsl(120, 100%, 50%)   /* pure green */
hsl(0,   0%,   50%)   /* mid gray */
hsl(220, 83%,  53%)   /* tooljo brand */

Use when:

HSL’s gotcha: equal numeric changes in L don’t produce equal perceived changes. The jump from hsl(50, 100%, 50%) to hsl(50, 100%, 60%) looks bigger than the same jump at hsl(220, 100%, 50%) to hsl(220, 100%, 60%). This is why design systems built on HSL palettes have been finicky for decades.

OKLCH — perceptually uniform

OKLCH was added to CSS Color Module 4 (~2023). It’s a polar representation of the OKLab color space, designed by Björn Ottosson specifically to fix HSL’s perceptual non-uniformity.

oklch(54% 0.21 263)   /* tooljo brand */
oklch(80% 0.16 263)   /* lighter — looks "lighter" */
oklch(40% 0.16 263)   /* darker — looks "darker" */

The key property: equal numeric changes in L produce equal perceived changes in lightness. Same for C. This makes OKLCH ideal for:

Use when:

Don’t use when:

Decision flowchart

Are you specifying a single color in CSS or a design tool?
└── Hex (#2563eb)

Are you doing image processing or per-pixel manipulation?
└── RGB (or its float-version, often called RGB-A or normalized RGB)

Are you generating a palette of related colors?
├── Modern stack with browser support OK?
│   └── OKLCH (perceptually uniform)
└── Need to support older browsers?
    └── HSL (varies lightness across a hue, accept perceptual unevenness)

Do you need alpha (transparency)?
├── In a literal? → 8-digit hex (#RRGGBBAA) or rgba()
└── In OKLCH/HSL? → Use the slash syntax: oklch(54% 0.21 263 / 0.5)

Are you printing? Working with brand specifications?
└── CMYK (different topic, ICC profiles required)

Common color-system mistakes

Building a palette in HSL

Tailwind v3 uses HSL for its color scale (blue-50, blue-100, …, blue-900). The result: not all 11 shades feel evenly spaced perceptually. Tailwind v4 switched to OKLCH, and the gradient feels visibly smoother.

If you’re building a new design system in 2026, start in OKLCH.

Mixing color spaces in a single palette

Picking blue-500 from HSL math and blue-600 from a designer’s intuition gives you two colors that don’t relate predictably. Pick one parameterization and use it consistently.

Using RGB component math for “lighter”

rgb(r * 1.2, g * 1.2, b * 1.2) doesn’t make a color “20% lighter.” It clips bright channels and scales dark channels disproportionately. Convert to HSL or OKLCH, increment L, convert back.

Browser support (early 2026)

FormatChromeSafariFirefox
HexAllAllAll
rgb()AllAllAll
hsl()AllAllAll
rgba()AllAllAll
hsla()AllAllAll
8-digit hexAll12+49+
oklch()111+15.4+113+
oklab()111+15.4+113+
lab(), lch()111+15+113+
color-mix()111+16.2+113+
color() (with display-p3, etc.)111+15+113+

OKLCH and friends are safe to use on the modern web. For older browsers, fall back to hex via @supports (color: oklch(54% 0.21 263)).

Try the tools