← All tools Design

HEX/RGB/HSL Color Converter

Convert colors between HEX, RGB, and HSL formats with a live preview and accessibility contrast checker.

Synced: #ff5733

rgb(255, 87, 51)

R
G
B

hsl(11, 100%, 60%)

H
S
L
color: #ff5733;
background-color: #ff5733;
border-color: #ff5733;
Aa SampleOn white background
3.15:1AA Large
Aa SampleOn black background
6.66:1AA

Understanding Color Formats in CSS

CSS supports multiple ways to define colors, each with different strengths. Choosing the right format depends on your use case — whether you are building a design system, ensuring accessibility, or fine-tuning a single shade.

The Three Main Color Formats

HEX (#RRGGBB)

The most compact format. Each pair of hex digits represents Red, Green, and Blue channels (00-FF). Shorthand like #F00 expands to #FF0000.

RGB (Red, Green, Blue)

Defines colors using three integer values from 0 to 255. Most intuitive when you need to programmatically adjust individual color channels or work with alpha transparency.

HSL (Hue, Saturation, Lightness)

The most human-friendly format. Hue is a degree on the color wheel (0-360), Saturation controls vibrancy (0-100%), and Lightness controls brightness (0-100%). Ideal for design systems.

Color Accessibility and Contrast

The Web Content Accessibility Guidelines (WCAG) specify minimum contrast ratios to ensure text is readable for all users. Normal text requires a contrast ratio of at least 4.5:1 against its background, while large text (18px bold or 24px regular) needs at least 3:1. This tool calculates the contrast ratio of your selected color against both white and black backgrounds.

Building Color Palettes with HSL

HSL is particularly powerful for creating consistent color palettes. Keep the hue constant and vary the saturation and lightness to generate a range of shades. For example, your primary brand color might be hsl(210, 80%, 50%), and you can create a lighter variant at hsl(210, 80%, 85%) and a darker one at hsl(210, 80%, 30%) — all harmonious because they share the same hue.

Frequently Asked Questions

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

HEX is hexadecimal notation. RGB uses Red/Green/Blue channel values (0-255). HSL uses Hue/Saturation/Lightness, which is more intuitive for creating color variations.

Which format should I use in CSS?

HEX is compact. RGB is best for programmatic adjustments. HSL is ideal for design systems where you need consistent color variations.

What is color contrast ratio?

It measures luminance difference between two colors. WCAG requires 4.5:1 for normal text and 3:1 for large text for accessibility compliance.

How does HEX to RGB conversion work?

A HEX color is split into three hex pairs (RR, GG, BB), each converted to decimal (0-255). For example, #FF5733 becomes RGB(255, 87, 51).

Can I use the native color picker?

Yes. The tool includes a native color picker that opens your OS color dialog. All three formats update in sync when you pick a color.

Related Tools