Ad
DevToolXDevToolX

Color Converter

Convert between HEX, RGB and HSL color formats

About Color Converter

Color formats are different notations for the same underlying data, but they are not equally convenient to work with. HEX is compact and universal; RGB maps to display hardware; HSL lets you intuitively adjust lightness and saturation; OKLCH adds perceptual uniformity so equal numeric steps produce equal-looking changes. This tool converts between all four, including alpha channels, so you can move freely between a designer's deliverables and your CSS codebase.

Common Use Cases

Convert designer HEX values to HSL CSS variables
shadcn/ui and many design systems store colors as `--color-primary: 220 90% 56%` in HSL. Paste the designer's #3B82F6 here, get the HSL numbers, and drop them straight into your CSS variables.
Check contrast ratios for accessibility
Convert your text and background colors to relative luminance (calculated from linear RGB) to verify you meet WCAG AA (4.5:1 for normal text, 3:1 for large text) before shipping.
Generate tonal variations of a brand color
Lock the hue and saturation in HSL, then sweep lightness from 10% to 90% to build a full color scale — the same technique used by Tailwind's color palette generator.
Debug Tailwind / shadcn theme tokens
Tailwind v3 uses HSL for theme colors. When a computed value looks wrong on screen, convert it here to see what hex color it resolves to and compare it against your design spec.

Frequently Asked Questions

What is the difference between HEX and RGB?

They carry identical information: red, green, and blue channel intensities from 0–255. HEX is just base-16 notation (#FF0000 = rgb(255, 0, 0)). Use whichever your context demands — CSS accepts both.

Why is HSL easier to manipulate than RGB?

RGB stores raw channel values that don't map intuitively to 'make this lighter' or 'shift the hue'. HSL separates hue (0–360°), saturation (0–100%), and lightness (0–100%), so you can tweak one dimension without recalculating the others.

What is OKLCH and why should I care?

OKLCH (OK Lightness, Chroma, Hue) is a perceptually uniform color space: a step of +10% lightness looks equally different regardless of the starting hue. HSL is not perceptually uniform — a yellow at 80% lightness looks much brighter than a blue at the same value. CSS Color Level 4 ships `oklch()` natively, and Tailwind v4 uses it internally.

How do alpha channels work across formats?

In CSS you can append a fourth component: `rgba(255, 0, 0, 0.5)`, `hsla(0, 100%, 50%, 0.5)`, or 8-digit hex `#FF000080` (last two hex digits = alpha 0–255). The alpha value is 0 (fully transparent) to 1 in CSS functions, or 0–255 in 8-digit hex.

What is sRGB, and does it cover all colors modern displays can show?

sRGB is the standard color space for the web and covers about 35% of visible colors. Modern displays (P3 wide gamut) can render roughly 50% of visible colors. CSS Color Level 4 lets you target P3 with `color(display-p3 r g b)`, but sRGB remains the safe default for cross-device consistency.

Related Tools