Color Converter — HEX, RGB & HSL

HEX
RGB
HSL
CSS

Aa
Aa

What is a Color Converter?

A color converter translates color values between different color models — the mathematical systems used to describe colors digitally. The three most common models on the web are HEX, RGB, and HSL. Each represents the same colors, but in different ways that suit different tasks. Designers, front-end developers, and anyone working with CSS regularly need to convert between these formats.

Color Models Explained

HEX (#RRGGBB)

Hex color codes are the most compact way to write a color in CSS. The format #RRGGBB uses six hexadecimal digits — two for each of the red, green, and blue channels. Each channel ranges from 00 (0, no intensity) to FF (255, full intensity). For example, #FF0000 is pure red, #00FF00 is pure green, and #FFFFFF is white. A shorthand form exists for colors with repeated digits: #F00 equals #FF0000.

RGB (Red, Green, Blue)

RGB defines colors by specifying how much red, green, and blue light to mix, with each channel as a decimal value from 0 to 255. This model maps directly to how screens produce color — each pixel has red, green, and blue sub-pixels. In CSS, it is written as rgb(255, 0, 0). RGB is intuitive when you think in terms of light mixing: red + green = yellow, red + blue = magenta, all three at full = white.

HSL (Hue, Saturation, Lightness)

HSL describes colors the way humans tend to think about them. Hue is the color angle on a 360-degree wheel (0 = red, 120 = green, 240 = blue). Saturation (0-100%) controls vibrancy — 0% is gray, 100% is the purest color. Lightness (0-100%) controls brightness — 0% is always black, 100% is always white, and 50% gives the most vivid color. HSL makes it easy to create color variations: keep the hue, adjust saturation for muted/vivid variants, or adjust lightness for tints and shades.

Color in CSS

CSS supports several color formats, all of which ultimately resolve to RGB values in the browser:

Newer CSS specifications introduce oklch(), oklab(), and color() for perceptually uniform color spaces, but HEX/RGB/HSL remain the day-to-day workhorses for web development.

WCAG Contrast and Accessibility

Color choices directly impact accessibility. The Web Content Accessibility Guidelines (WCAG) define minimum contrast ratios between text and its background: 4.5:1 for normal text (AA), 3:1 for large text (AA Large), and 7:1 for the highest level (AAA). This tool calculates the contrast ratio of your selected color against both black and white backgrounds, so you can verify your colors meet accessibility standards before writing any code.

How to Use This Tool

  1. Enter a color in any format — type a hex code in the HEX field, set RGB values with the number inputs, or adjust HSL values directly.
  2. Use the color picker to select a color visually — all fields update in real time.
  3. Read the CSS output to get both rgb() and hsl() values ready to paste into your stylesheet.
  4. Check the Contrast Ratio section to verify WCAG accessibility against black and white backgrounds.
  5. Explore Color Harmonies — complementary, triadic, analogous, and split complementary — to find colors that work well together. Click any harmony swatch to load it as the active color.

Everything runs in your browser. No data is sent to any server.

Frequently Asked Questions

What is a hex color code?

A hex color code is a six-character string prefixed with # that represents a color using hexadecimal notation. The format is #RRGGBB, where each pair represents the red, green, and blue channels as values from 00 (0) to FF (255). For example, #FF0000 is pure red and #000000 is black.

How do I convert RGB to hex?

To convert RGB to hex, convert each channel value (0-255) to a two-digit hexadecimal number and concatenate them. For example, RGB(59, 130, 246) becomes #3B82F6: 59 = 3B, 130 = 82, 246 = F6. This tool performs the conversion automatically as you type.

What is HSL?

HSL stands for Hue, Saturation, and Lightness. Hue is the color angle on a 360-degree color wheel (0 = red, 120 = green, 240 = blue). Saturation (0-100%) controls how vivid the color is. Lightness (0-100%) controls how bright it is, where 0% is black and 100% is white. HSL is often more intuitive than RGB for choosing colors.

What's the difference between RGB and HSL?

RGB defines colors by mixing red, green, and blue light — it maps directly to how screens display color. HSL defines colors by hue, saturation, and lightness — it maps more closely to how humans perceive color. Use RGB when you need precise channel control; use HSL when you want to adjust brightness or vibrancy intuitively.

What does opacity/alpha mean in colors?

Alpha (or opacity) is a fourth channel that controls transparency. A value of 1 (or 255 or FF) is fully opaque, and 0 is fully transparent. In CSS, you can specify it with rgba(255, 0, 0, 0.5) for 50% transparent red, or #FF000080 using 8-digit hex notation.

How do CSS color formats work?

CSS supports several color formats: hex (#FF0000), rgb(255, 0, 0), hsl(0, 100%, 50%), named colors (red), and modern formats like oklch() and color(). All of these ultimately get converted to RGB values by the browser. Hex is the most compact, HSL is the most readable, and rgb() is the most explicit.