Color Converter (HEX ↔ RGB ↔ HSL)


HEX, RGB & HSL Color Formats Explained

Web browsers and design tools represent sRGB colors in three primary notations: hexadecimal (HEX), Red-Green-Blue (RGB), and Hue-Saturation-Lightness (HSL). All three describe the exact same color space, so converting between them is lossless and reversible.

How Each Format Works

  • HEX (#RRGGBB or #RGB): Encodes Red, Green, and Blue channels as two-digit base-16 numbers from 00 (0) to FF (255). For example, #3b82f6 means Red=59, Green=130, Blue=246. Three-digit shorthand like #f0a expands to #ff00aa.
  • RGB (rgb(r, g, b)): Expresses each channel as a decimal integer from 0 to 255. Convenient when programmatically blending colors or adding an alpha channel with rgba(59, 130, 246, 0.5).
  • HSL (hsl(h, s%, l%)): Represents color the way humans perceive it: Hue (0°–360° on the color wheel, where 0° is red, 120° is green, 240° is blue), Saturation (0%–100% intensity), and Lightness (0% black, 50% pure hue, 100% white).

When to Use HSL in CSS & FAQ

  • Why is HSL great for design systems? To build hover states, borders, or dark-mode variants of a brand color, you keep the Hue constant and simply adjust Lightness by ±10% (e.g., hsl(217, 91%, 60%) → hsl(217, 91%, 50%)).
  • Does the native Color Picker sync all fields? Yes. Picking any shade in the browser color picker, typing a 3- or 6-digit HEX code, or entering rgb(...) / hsl(...) updates the live preview swatch and all other formats instantaneously.
  • Are conversions sent to a server? No, all math runs locally in JavaScript.

Accessibility & Contrast Guidelines

When picking foreground text and background colors for UI buttons, badges, or alerts, aim for a minimum WCAG AA contrast ratio of 4.5:1 for body text and 3:1 for large headings or UI borders. Converting colors to HSL makes it easy to test accessibility: if a saturated blue like hsl(217, 91%, 60%) looks too bright behind white text, lowering Lightness to 45% (#1d4ed8) immediately improves legibility while keeping the exact same brand hue.

Please read the privacy policy (agreement of the cookies usage, other websites embedded content, etc.). If you continue to use the site, we will assume that you agree with our privacy policy.
OkPrivacy Policy