How do you convert colors between HEX, RGB and HSL?
Color formats describe the same color in different ways: HEX and RGB mix red, green and blue light, HSL and HSV use hue, saturation and lightness or value, CMYK is used in print, and LAB and OKLCH are perceptual models. Enter a color in any of these formats, a CSS name, or use the picker, and this color converter shows all the others at once, ready to copy. A WCAG contrast checker tests readability.
How to convert a color from HEX to RGB or HSL
- 1
Type a color such as #3B82F6, rgb(59, 130, 246), hsl(217 91% 60%), cmyk(76%, 47%, 0%, 4%) or tomato, or pick one with the color box.
- 2
Read the converted values for HEX, RGB, HSL, HSV, HWB, CMYK, LAB and OKLCH.
- 3
Copy the format you need with its copy button.
- 4
Use the contrast checker to compare the color against a background and see the WCAG AA and AAA results.
Key features
Eight formats at once
HEX, RGB, HSL, HSV, HWB, CMYK, CIE LAB and OKLCH are calculated together and written in modern CSS syntax.
Flexible input
Paste HEX with or without #, rgb() and hsl() functions, CSS color names, CMYK, HSV or plain red, green, blue numbers.
WCAG contrast checker
Get the exact contrast ratio between two colors and see whether it passes AA and AAA for normal and large text.
Transparency support
Alpha values in rgba(), hsla() and 8-digit HEX are preserved in the converted output.
Frequently asked questions
How do I convert HEX to RGB?
Split the six-digit HEX code into three pairs and convert each from base 16 to decimal. For example #3B82F6 becomes 59, 130 and 246, written rgb(59 130 246). The tool does this automatically.
What is OKLCH?
OKLCH is a perceptual color space with lightness, chroma and hue, supported by modern CSS as oklch(). Equal changes in its values look like equal changes in color, which makes it good for building palettes.
Why is CMYK different on screen and in print?
CMYK is a subtractive model for ink and the simple conversion used here ignores printer profiles. Screens can show colors that no ink can reproduce, so printed results can look duller.
What contrast ratio is required by WCAG?
WCAG 2 AA requires at least 4.5:1 for normal text and 3:1 for large text. AAA requires 7:1 for normal text and 4.5:1 for large text.
What is the difference between HSL and HSV?
Both describe hue and saturation, but HSL uses lightness, where 100% is always white, while HSV uses value, where 100% is the brightest version of the hue. HSL is the one used in CSS.