Skip to content
hexcolorcodepicker.com

HEX vs RGB vs HSL

One color, three notations

HEX, RGB, and HSL are three ways to write the same color, not three different colors. The bright blue #3B82F6 is rgb(59, 130, 246) and hsl(217, 91%, 60%) at the same time. Pick the form that fits the job, and the color stays the same.

HEX is the shortest form and the web default, RGB is the form code and screens use underneath, and HSL is the form that makes it easy to lighten, darken, or desaturate a color. A converter changes the writing without changing the color, as long as the values are exact. Rounding can shift channels by 1, so a converted color may come back as a near neighbor, not an exact twin.

Worked example — #3B82F6 in all three notations

#3B82F6 = rgb(59, 130, 246) = hsl(217, 91%, 60%) = hsv(217°, 76%, 96%). The HEX pairs are 3B (59), 82 (130), and F6 (246). The hue is 217 degrees, a blue just short of pure blue. HSL lightness is 60 percent, and HSV value is 96 percent, because the brightest channel, 246, is 96 percent of 255.

One color, three names — change any card and the others follow.

All three cards name the same blue: #3B82F6.

Comparison table

The table below compares HEX, RGB, and HSL by format, example, range, and best use. HEX is best for pasting a color into CSS, RGB is best for code that reads channel values, and HSL is best for adjusting a color.

Read the table row by row, then try the example color in each form. HEX stores 3 hex pairs, RGB stores 3 decimals from 0 to 255, and HSL stores a hue angle plus 2 percents. The ranges look different, but they describe the same 16,777,216 colors. The "best for" column is the real difference: each form is built for a different job, and using the wrong one makes simple edits harder than they need to be.

FormatExampleRange
HEX#3B82F600–FF per channel (0–255)
RGBrgb(59, 130, 246)0–255 per channel
HSLhsl(217, 91%, 60%)Hue 0–360°, saturation 0–100%, lightness 0–100%

HEX — best for: pasting a color into CSS, HTML, or a design tool.

HEX: the web default

HEX is the shortest form and the one most web code uses. A developer writes color: #3B82F6; in CSS, a designer pastes the same code into Figma, and a brand guide lists it so every page uses the same blue. It is compact, exact, and easy to copy.

HEX packs 3 channel values into 6 digits after a hash sign, so it takes less space than rgb() and is easier to scan in a stylesheet. Its weakness is that the numbers are hard to read: you cannot tell at a glance whether #3B82F6 is light or dark, or how to make it lighter. That is why HEX is best for storing and sharing a color, not for adjusting one. See our guide on what is a HEX color code for the full #RRGGBB anatomy.

.button {
  color: #3B82F6;
  background: #3B82F6;
}

Lightening by hand means changing all 6 digits — that is why HEX is for storing a color, not adjusting one.

RGB: the screen's own numbers

RGB writes the same color as 3 decimals from 0 to 255, one per light channel. The code rgb(59, 130, 246) means 59 red, 130 green, and 246 blue, which is the same blue as #3B82F6. Screens mix red, green, and blue light, so RGB is the form closest to the hardware.

RGB is the form canvas code, image code, and many APIs expect, because they read channel values directly. Its alpha form, rgba(), adds a fourth number from 0 to 1 for transparency, such as rgba(59, 130, 246, 0.5) for half-transparent blue. RGB shares HEX's weakness: lightening a color means changing all 3 numbers at once, with no single control for lightness. See our guides on converting HEX to RGB by hand and converting RGB to HEX by hand.

#3B82F6

Drag a bar: the HEX code and the swatch update, so you see each channel's share of the color.

HSL: the human-friendly form

HSL writes a color as hue, saturation, and lightness, which match how people think about color. The code hsl(217, 91%, 60%) means a blue hue at 217 degrees, 91 percent saturated, and 60 percent light. To lighten it, raise the lightness; to mute it, lower the saturation.

Hue is an angle from 0 to 360 degrees: 0 is red, 120 is green, 240 is blue, and 217 sits just short of pure blue. Saturation is how vivid the color is, from gray to full color. Lightness is how bright it is, from 0 percent black through 50 percent pure color to 100 percent white. But equal lightness does not mean equal brightness: a yellow at 50 percent lightness looks brighter than a blue at 50 percent lightness.

hsl(217, 91%, 60%) → #3B82F6

Move the lightness slider: #3B82F6 lightens or darkens in one move, while the HEX code updates beside it.

HSV vs HSL: value is not lightness

HSV and HSL share the same hue, but they measure brightness differently. HSV uses value, which is the brightest channel, while HSL uses lightness, which is the average of the brightest and darkest channels. For #3B82F6, HSV is hsv(217°, 76%, 96%) and HSL is hsl(217, 91%, 60%).

Value runs from black at 0 percent to the full color at 100 percent, and it never goes past the color into white. Lightness runs from black at 0 percent through the full color at 50 percent to white at 100 percent. That is why a picker square uses HSV: its saturation and value axes map neatly to a square. HSL is better for building color scales, because raising lightness gives clean tints and lowering it gives clean shades.

HSV

hsv(217°, 76%, 96%)

HSL

hsl(217, 91%, 60%)

Move the value slider, then the lightness slider: the same hue reaches white only in HSL, while HSV stops at the full color.

When to use each format

Use HEX to store and share a color, RGB when code needs channel values, and HSL when you need to adjust a color. A brand guide lists HEX, a canvas script reads RGB, and a design system builds its tints and shades in HSL, then ships them as HEX.

A common workflow is to pick a color in HEX, convert it to HSL to make a lighter hover state and a darker border, then convert those back to HEX for the stylesheet. That keeps the CSS short while the thinking happens in HSL. Do not mix forms in one file without a reason: it makes the code harder to scan. If a tool needs a form you do not have, use the Color Converter to change the writing without changing the color.

HEX — #3B82F6

Short, exact, easy to copy: paste it into CSS, HTML, or a design tool.

The same blue, cmyk(76%, 47%, 0%, 4%) in CMYK (approximate) — the format changes, the color does not. The HSL round trip gives #3C83F6, and the HSV round trip gives #3B82F5: a 1-point rounding shift.

Frequently asked questions

Neither is better: they name the same color in different forms. HEX is shorter and easier to paste into CSS, while RGB is easier to read as 3 numbers and is what canvas code expects. Convert between them freely; the color does not change.