Color Picker & Converter
Convert a color between HEX, RGB, HSL, OKLCH and CMYK. Paste any of those formats or a CSS color name, and see WCAG contrast against white and black.
Type or paste a color. With no field focused, pasting anywhere on this page works too.
#ff7a59
#ff7a59 is rgb(255, 122, 89), hsl(12, 100%, 67%), oklch(72.9% 0.17 35.1)
01 · Definition
How do you convert HEX to RGB?
A hex color is three two-digit base-16 numbers for red, green and blue. To convert it to RGB, split the six digits into pairs and read each pair as a number from 0 to 255: #ff7a59 is ff = 255, 7a = 122, 59 = 89, so rgb(255, 122, 89).
02 · Overview
How the Color Picker & Converter works
This tool converts one color at a time. Type or paste a hex code (3, 4, 6 or 8 digits), rgb(), hsl(), oklch() or a CSS color name, or use the color picker. The tool shows the same color as HEX, RGB, HSL, OKLCH and CMYK, the exact or nearest CSS named color, and its WCAG contrast ratio against white and against black. An oklch() value outside the sRGB gamut is flagged and mapped to the nearest sRGB color. Conversions run in your browser.
03 · Guide
HEX, RGB, HSL and OKLCH compared
All four notations can describe the same sRGB color. They differ in what the numbers mean, which decides how easy the value is to adjust by hand.
| Format | Value | What the numbers are |
|---|---|---|
| HEX | #ff7a59 | Red, green, blue as base-16 pairs, 00 to ff |
| RGB | rgb(255, 122, 89) | Red, green, blue from 0 to 255 |
| HSL | hsl(12, 100%, 67%) | Hue angle, saturation, lightness |
| OKLCH | oklch(72.9% 0.17 35.1) | Perceptual lightness, chroma, hue angle |
| CMYK | cmyk(0%, 52%, 65%, 0%) | Ink percentages, estimated without a color profile |
04 · Guide
What contrast ratio does WCAG require?
WCAG 2 asks for a contrast ratio of at least 4.5:1 between text and its background at level AA, and 7:1 at level AAA. Large text, meaning at least 18 point or 14 point bold, needs 3:1 at AA and 4.5:1 at AAA. User interface components and graphics need 3:1. The ratio is not rounded up, so 4.49:1 fails 4.5:1.
The tool reports the ratio of your color against white and against black with the level it reaches. The rows below were computed with the WCAG relative-luminance formula and rounded down to two decimals, as the tool does.
| Color | On white | On black |
|---|---|---|
| #595959 | 7.00:1 (AAA) | 2.99:1 (fails AA) |
| #767676 | 4.54:1 (AA) | 4.62:1 (AA) |
| #949494 | 3.03:1 (large text and UI only) | 6.92:1 (AA) |
| #663399 rebeccapurple | 8.40:1 (AAA) | 2.49:1 (fails AA) |
| #ff7a59 | 2.56:1 (fails AA) | 8.18:1 (AAA) |
| #ff0000 red | 3.99:1 (large text and UI only) | 5.25:1 (AA) |
05 · Use cases
When to use the Color Picker & Converter
- 01
Convert a hex code into rgb() or hsl() for a stylesheet
- 02
Get the OKLCH equivalent of a hex color for use in Tailwind v4
- 03
Find the CSS named color nearest to a hex value
- 04
Check whether a color has enough contrast against white or black text
06 · Examples
Color Picker & Converter examples
#ff7a59
ex 01rgb(255, 122, 89) · hsl(12, 100%, 67%) · oklch(72.9% 0.17 35.1) · cmyk(0%, 52%, 65%, 0%)
A hex code converted to the other four formats.
rgb(48, 209, 88)
ex 02#30d158 · hsl(135, 64%, 50%) · nearest named: limegreen
limegreen is #32cd32, so the tool labels it nearest, not exact.
rebeccapurple
ex 03#663399 · rgb(102, 51, 153) · hsl(270, 50%, 40%) · 8.40:1 on white (AAA)
A CSS named color resolved to its values, with its contrast against white.
oklch(73% 0.16 30)
ex 04#fc7c69 · rgb(252, 124, 105) · hsl(8, 96%, 70%)
An OKLCH value inside sRGB, converted to the older formats.
oklch(70% 0.37 145)
ex 05Outside the sRGB gamut. Nearest sRGB color #00bf34, chroma reduced from 0.37 to 0.22
A wide-gamut green. The tool flags it and keeps lightness and hue while lowering chroma.
#ff7a5980
ex 06rgba(255, 122, 89, 0.502) · hsla(12, 100%, 67%, 0.502)
Eight-digit hex carries alpha: 80 is 128 of 255, or about 50%.
07 · FAQ
Color: frequently asked questions
Which color formats can I paste in?
Is OKLCH lossless from sRGB?
How accurate is the CMYK conversion?
What does 'nearest named color' mean?
Which color format should I use in CSS?
How is the contrast ratio calculated?
Can hex codes include transparency?
08 · Guides
Color guides
- HEX vs RGB vs HSL vs OKLCH: CSS Color Formats Compared→
HEX and RGB give red, green and blue. HSL gives hue, saturation and lightness. OKLCH gives perceptual lightness, chroma and hue. With conversion tables.
09 · Reference
Specs and further reading
These are the primary sources this tool follows. Where a specification defines the behaviour, we link the specification, not a summary of it.
- CSS Color Module Level 4
W3C. Normative definitions for hex, rgb, hsl, oklch, named colors, and conversion between them.
- <color> data type
MDN Web Docs. Practical reference for every CSS color notation this tool converts between.
- Understanding SC 1.4.3: Contrast (Minimum)
W3C WAI. Defines the contrast ratio and the 4.5:1 and 3:1 thresholds the tool reports against.
- Understanding SC 1.4.6: Contrast (Enhanced)
W3C WAI. The level AAA thresholds: 7:1 for text and 4.5:1 for large text.
- Understanding SC 1.4.11: Non-text Contrast
W3C WAI. The 3:1 threshold for user interface components and graphics.
10 · More
Tools that pair with Color
Color Palette GeneratorAI-powered
Type a vibe such as 'desert at dusk' or 'cyberpunk lab' and get a 5-color palette with hex, RGB, HSL and OKLCH for every swatch.
CSS Gradient Generator
Build linear, radial and conic CSS gradients with 2 to 8 color stops. Drag the stops or type exact values, then copy the CSS or a Tailwind class.
CSS Box Shadow Generator
Build CSS box shadows with sliders for offset, blur, spread, color and opacity. Stack up to 6 layers, preview live, copy as CSS or Tailwind.