Color Formats Explained: HEX, RGB, HSL, HSV, and CMYK

Color formats define how colors are represented in digital systems. The five most common formats are HEX, RGB, HSL, HSV (also called HSB), and CMYK. Each serves different purposes: RGB and HEX dominate web development, HSL and HSV help designers adjust colors intuitively, and CMYK is essential for print.

This guide explains how each format works, provides conversion formulas with examples, and helps you choose the right format for your project.

Quick Reference: When to Use Each Format

Format Best For Example
HEX Web development, CSS #FF5733
RGB Screen displays, CSS rgb(255, 87, 51)
HSL Adjusting brightness/saturation hsl(14, 100%, 60%)
HSV/HSB Design software (Photoshop, Figma) hsv(14°, 80%, 100%)
CMYK Print design cmyk(0%, 66%, 80%, 0%)

HEX Color Codes

HEX (hexadecimal) is a six-character code that represents colors using base-16 notation. The format is #RRGGBB, where each pair represents red, green, and blue intensity from 00 to FF (0 to 255 in decimal).

How HEX Works

Each pair of characters encodes one color channel:

The characters 0-9 and A-F represent values 0-15. Two characters together give 16 × 16 = 256 possible values per channel.

HEX Examples

Color HEX Code Breakdown
Pure red #FF0000 Red=255, Green=0, Blue=0
Pure green #00FF00 Red=0, Green=255, Blue=0
Pure blue #0000FF Red=0, Green=0, Blue=255
White #FFFFFF All channels at maximum
Black #000000 All channels at zero
Orange #FF5733 Red=255, Green=87, Blue=51

Shorthand HEX

When each pair has identical digits, you can use three-character shorthand:

Converting HEX to Decimal

To convert a HEX pair to decimal, multiply the first digit by 16 and add the second:

RGB Color Model

RGB (Red, Green, Blue) is an additive color model where colors are created by combining light. Each channel ranges from 0 to 255, giving 16.7 million possible colors (256³).

How RGB Works

RGB is called "additive" because adding colors together creates lighter colors:

This matches how screens work: they emit red, green, and blue light that combines in your eyes.

RGB Syntax in CSS

/* Standard RGB */
color: rgb(255, 87, 51);

/* RGB with alpha (transparency) */
color: rgba(255, 87, 51, 0.5);

/* Modern CSS (alpha as percentage) */
color: rgb(255 87 51 / 50%);

Converting HEX to RGB

To convert HEX to RGB, convert each pair from base-16 to base-10:

Example: #FF5733 to RGB

Converting RGB to HEX

To convert RGB to HEX, convert each decimal value to two-digit hexadecimal:

Example: rgb(255, 87, 51) to HEX

HSL Color Model

HSL (Hue, Saturation, Lightness) represents colors in a way that matches human perception. Instead of mixing primary colors, you specify the color type, its intensity, and brightness.

HSL Components

Hue (0-360°): The color's position on the color wheel

Saturation (0-100%): Color intensity

Lightness (0-100%): Brightness level

Why Designers Prefer HSL

HSL makes color adjustments intuitive:

In RGB, these adjustments require changing multiple values in non-obvious ways.

HSL Syntax in CSS

/* Standard HSL */
color: hsl(14, 100%, 60%);

/* HSL with alpha */
color: hsla(14, 100%, 60%, 0.5);

/* Modern CSS */
color: hsl(14 100% 60% / 50%);

Converting RGB to HSL

The conversion formula:

  1. Normalize RGB values to 0-1 range (divide by 255)
  2. Find the maximum and minimum values
  3. Calculate lightness: L = (max + min) / 2
  4. Calculate saturation:
  5. Calculate hue based on which channel is maximum

Example: rgb(255, 87, 51) to HSL

HSV/HSB Color Model

HSV (Hue, Saturation, Value) is similar to HSL but measures brightness differently. HSV is also called HSB (Hue, Saturation, Brightness). It's the default color model in Photoshop, Figma, and most design software.

HSV vs HSL: Key Difference

The main difference is how they handle brightness:

HSL Lightness:

HSV Value/Brightness:

This means:

When to Use HSV vs HSL

CMYK Color Model

CMYK (Cyan, Magenta, Yellow, Key/Black) is a subtractive color model used for printing. Unlike RGB which adds light, CMYK works by subtracting light—inks absorb certain wavelengths and reflect others.

How CMYK Works

On a white page:

Why Screens and Printers Show Different Colors

RGB screens emit light; CMYK printers absorb it. This fundamental difference means:

Always convert to CMYK before sending designs to print, and expect some color shift.

Converting RGB to CMYK

The formula (simplified, assumes RGB values are 0-1):

K = 1 - max(R, G, B)
C = (1 - R - K) / (1 - K)
M = (1 - G - K) / (1 - K)
Y = (1 - B - K) / (1 - K)

Example: rgb(255, 87, 51) to CMYK

Common Conversion Examples

Here are some frequently needed color conversions:

Web-Safe Colors

Color Name HEX RGB HSL
White #FFFFFF rgb(255, 255, 255) hsl(0, 0%, 100%)
Black #000000 rgb(0, 0, 0) hsl(0, 0%, 0%)
Red #FF0000 rgb(255, 0, 0) hsl(0, 100%, 50%)
Green #00FF00 rgb(0, 255, 0) hsl(120, 100%, 50%)
Blue #0000FF rgb(0, 0, 255) hsl(240, 100%, 50%)
Yellow #FFFF00 rgb(255, 255, 0) hsl(60, 100%, 50%)
Cyan #00FFFF rgb(0, 255, 255) hsl(180, 100%, 50%)
Magenta #FF00FF rgb(255, 0, 255) hsl(300, 100%, 50%)

Brand Colors (Examples)

Brand Approximate HEX RGB
Facebook Blue #1877F2 rgb(24, 119, 242)
YouTube Red #FF0000 rgb(255, 0, 0)
Twitter/X Black #000000 rgb(0, 0, 0)
LinkedIn Blue #0A66C2 rgb(10, 102, 194)
Spotify Green #1DB954 rgb(29, 185, 84)

Color Format Comparison

Aspect HEX RGB HSL HSV CMYK
Primary use Web Web/Screen Web/Design Design software Print
Intuitive adjustments No No Yes Somewhat No
CSS support Yes Yes Yes No No
Total colors 16.7M 16.7M 16.7M 16.7M Varies
Transparency #RRGGBBAA rgba() hsla() No No

Tools and Practical Applications

Quick Conversions

Use our Color Converter to instantly convert between all formats. Enter any color value and get HEX, RGB, HSL, HSV, and CMYK outputs with one click copy.

Creating Color Palettes

  1. Start with a base color in HSL
  2. Create variations by adjusting:

Accessibility Considerations

Color contrast matters for readability. The WCAG 2.1 guidelines require:

Use luminance (calculated from RGB) to check contrast:

Luminance = 0.299 × R + 0.587 × G + 0.114 × B

FAQ

What is the difference between HEX and RGB?

HEX and RGB represent the same colors differently. HEX uses hexadecimal notation (#FF5733), while RGB uses decimal notation (rgb(255, 87, 51)). They're interchangeable for web development—choose based on preference or code style guidelines.

Why does my printed color look different from my screen?

Screens use RGB (additive light), while printers use CMYK (subtractive ink). The color gamuts don't fully overlap, so some screen colors can't be printed exactly. Always convert to CMYK and do a test print for color-critical work.

What is the best color format for CSS?

HEX and RGB are equally well-supported. Use HSL when you need to programmatically adjust brightness or saturation, as it maps more intuitively to human perception. Modern CSS supports all three.

How do I convert HEX to RGB manually?

Convert each pair of HEX digits to decimal. For example, #FF5733: FF = 255, 57 = 87, 33 = 51, giving rgb(255, 87, 51). Multiply the first digit by 16 and add the second.

What does the alpha channel do?

The alpha channel controls transparency. A value of 1 (or 100% or FF) is fully opaque; 0 is fully transparent. Use rgba(), hsla(), or 8-digit HEX (#RRGGBBAA) to specify alpha.

Why is HSL better for adjusting colors?

HSL separates color (hue) from intensity (saturation) and brightness (lightness). To darken a color, just decrease lightness. In RGB, you'd need to decrease all three channels proportionally—less intuitive.

What's the difference between HSL and HSV?

Both use hue and saturation, but measure brightness differently. HSL's lightness goes from black (0%) through pure color (50%) to white (100%). HSV's value goes from black (0%) to the brightest version of that color (100%), not white.

Can I use CMYK in web development?

No. Browsers don't support CMYK. Convert CMYK values to RGB or HEX for web use. CMYK is only for print design workflows.

What is a color gamut?

A color gamut is the range of colors a device can display or produce. RGB monitors have one gamut, CMYK printers have another. Colors outside a device's gamut can't be accurately reproduced on that device.

How many colors can HEX represent?

HEX can represent 16,777,216 colors (256 × 256 × 256). This is the same as RGB, since HEX is just a different notation for the same values.

What are web-safe colors?

Web-safe colors were a palette of 216 colors that displayed consistently on old 8-bit monitors. They're no longer relevant—modern displays support millions of colors.

How do I find a color's complementary color?

In HSL or HSV, add 180° to the hue. For example, the complement of hsl(60, 100%, 50%) (yellow) is hsl(240, 100%, 50%) (blue).

Why is black called "Key" in CMYK?

"Key" refers to the key plate in printing—the plate that adds detail and contrast. Using "K" also avoids confusion with "B" for blue in RGB.

Can I use HEX colors in Photoshop?

Yes. Photoshop accepts HEX input in its color picker. However, Photoshop's native color model is HSB (same as HSV), so that's what you'll see in the interface.

How do I make a color lighter in CSS?

Use HSL and increase the lightness value. For example, change hsl(200, 80%, 40%) to hsl(200, 80%, 60%) for a lighter shade. Alternatively, use CSS color-mix() or relative color syntax in modern browsers.

Related Tools