ConvertersApril 12, 2026

Color Format Converter Guide: HEX, RGB, HSL Explained

By The hakaru Team·Last updated March 2026

Quick Answer

  • *HEX: 6-character code (#FF5733). Compact, widely used in CSS and design tools.
  • *RGB: Red, Green, Blue channels (0–255 each). Best for programmatic color manipulation.
  • *HSL: Hue (0–360°), Saturation, Lightness. Most intuitive for creating palettes.
  • *All three represent the same 16.7 million colors — different notation, same result.

HEX Color Codes

HEX (hexadecimal) is the most common color format on the web. A HEX code starts with # followed by six characters representing red, green, and blue in base-16 notation. Each pair ranges from 00 (0) to FF (255).

#000000 is black (all channels at zero). #FFFFFF is white (all at maximum). #FF0000 is pure red. The shorthand #F00 expands to #FF0000. Case doesn’t matter: #ff5733 and #FF5733 are identical.

Eight-digit HEX codes add an alpha channel for transparency. #FF573380 is the same orange-red at 50% opacity. The last two digits control alpha from 00 (transparent) to FF (opaque).

RGB Color Model

RGB defines colors by mixing red, green, and blue light — the same principle your screen uses. Each channel takes a value from 0 to 255, giving 256 × 256 × 256 = 16,777,216 possible colors.

In CSS: rgb(255, 87, 51). The newer syntax drops commas: rgb(255 87 51). For transparency, add a slash: rgb(255 87 51 / 0.5) or use the legacy rgba(255, 87, 51, 0.5).

RGB is additive color mixing. Red + green = yellow. Red + blue = magenta. All three at full intensity = white. This is the opposite of paint mixing (subtractive color), which is why mixing all paint colors gives you brown, not white.

HSL Color Model

HSL stands for Hue, Saturation, Lightness. It maps colors to a cylinder where hue is the angle (0° = red, 120° = green, 240° = blue), saturation is the distance from the center (0% = gray, 100% = vivid), and lightness ranges from 0% (black) to 100% (white) with 50% being the pure color.

HSL is the most designer-friendly format. Want a darker shade? Decrease lightness. Want a pastel? Decrease saturation and increase lightness. Want an analogous color? Shift the hue by 30°. These operations are intuitive in HSL but require recalculating all three values in RGB.

Converting Between Formats

HEX to RGB

Split the hex code into three pairs. Convert each pair from base-16 to base-10. #3498DB: 34 = 52, 98 = 152, DB = 219. Result: rgb(52, 152, 219).

RGB to HSL

This conversion involves normalizing RGB values to 0–1, finding the min and max, calculating lightness as (max + min) / 2, saturation based on lightness, and hue based on which channel is dominant. The math is well-defined but tedious by hand — which is exactly why converter tools exist.

When to Use Each Format

HEX when you need compact notation in CSS or when copying colors from design tools. Most designers speak in hex codes.

RGB when manipulating colors programmatically in JavaScript, when working with canvas or WebGL, or when blending colors mathematically.

HSL when building design systems, creating color scales, generating hover/active states, or anytime you need to reason about colors intuitively. Tailwind CSS and many modern design systems use HSL internally.

Modern CSS Color Spaces

CSS Color Level 4 introduced oklch() and oklab(), which are perceptually uniform color spaces. In HSL, two colors with the same lightness value can look very different in brightness to human eyes. OKLCH fixes this by aligning lightness with human perception.

The color-mix() function lets you blend colors in any color space directly in CSS. And the color() function provides access to wide-gamut color spaces like Display P3, which modern screens can show but sRGB (and therefore traditional HEX/RGB) cannot represent.

Convert between HEX, RGB, and HSL instantly

Use our free Color Format Converter →

Frequently Asked Questions

What is the difference between HEX, RGB, and HSL?

HEX is a compact hexadecimal notation. RGB defines colors by red, green, and blue channel intensities (0–255). HSL uses hue, saturation, and lightness. All three represent the same 16.7 million colors — they’re just different ways to express them.

How do I convert HEX to RGB?

Split the 6-digit hex code into three pairs and convert each from hexadecimal to decimal. For #FF5733: FF = 255, 57 = 87, 33 = 51. So #FF5733 = rgb(255, 87, 51).

When should I use HSL over RGB?

Use HSL when creating color variations. It’s much easier to make a color lighter, darker, or less saturated by adjusting L and S values. For hover states, just decrease lightness by 10%.

What is the alpha channel in RGBA and HSLA?

The alpha channel controls transparency, ranging from 0 (fully transparent) to 1 (fully opaque). In modern CSS, use the slash syntax: rgb(255 0 0 / 50%).

What color format should I use in CSS?

HSL is often the best for design systems. HEX is the most compact. RGB is best for programmatic manipulation. All are supported in every modern browser. For perceptually uniform colors, consider oklch().