Color Format Converter
Convert a color between hex, RGB, HSL, OKLCH, Lab and other formats, and check its contrast against a background for accessible text.
- Free, no sign-up
- Runs in your browser
- Sources cited
Any CSS color: #hex, rgb(), hsl(), hwb(), lab(), lch(), oklab(), oklch(), color(), a name, or hsv() and cmyk().
The color the text or icon sits on. Leave empty to skip the contrast check.
- lowercase
- UPPERCASE
- Map (keep hue and lightness)
- Clip each channel
CSS
- Hex
- #2563eb
- RGB
- rgb(37 99 235)
- HSL
- hsl(221.21 83.19% 53.33%)
- HWB
- hwb(221.21 14.51% 7.84%)
- OKLCH
- oklch(54.61% 0.2152 262.88)
- OKLab
- oklab(54.61% -0.0267 -0.2135)
- CIE Lab
- lab(44.79% 21.05 -75.6)
- CIE LCH
- lch(44.79% 78.47 285.56)
Wide gamut and device-independent
- Display P3
- color(display-p3 0.2132 0.383 0.889)
- CIE XYZ (D65)
- color(xyz-d65 0.2022 0.1531 0.8049)
- HSV / HSB
- hsv(221.21 84.26% 92.16%)
- CMYK (simple, no profile)
- cmyk(84.26% 57.87% 0% 7.84%)
Code and other formats
- Decimal integer
- 2450411
- Android (ARGB)
- #FF2563EB
- Flutter
- Color(0xFF2563EB)
- SwiftUI
- Color(red: 0.145, green: 0.388, blue: 0.922)
- Tailwind class
- bg-[#2563eb]
Contrast
5.16:1- AA, normal textneeds 4.5:1Pass
- AA, large textneeds 3:1Pass
- AAA, normal textneeds 7:1Fail
- AAA, large textneeds 4.5:1Pass
- Icons and controlsneeds 3:1Pass
Closest colors that pass
How to use the color converter
Enter a color
Type or paste a color in any CSS syntax, use a color name, or pick one from the swatch. The tool tells you how it read the input.
Copy the format you need
Every format has its own copy button: CSS formats, wide-gamut spaces, and code for Android, Flutter, SwiftUI and Tailwind.
Set the output
Choose the decimal places, modern or legacy rgb() and hsl() syntax, lowercase or uppercase hex, and how colors outside sRGB are brought in.
Check the contrast
Enter a background to see the WCAG contrast ratio and which levels pass, with a live text sample.
Fix a failing pair
If the contrast is too low, the tool suggests the closest colors of the same hue that pass, and applies one with a click.
How color conversion works
Every format describes a color in some color space. Hex, rgb(), hsl() and hwb() all describe sRGB, the standard space of the web: hex and rgb() give its red, green and blue channels, while HSL and HWB rearrange the same values as hue with saturation and lightness, or with whiteness and blackness. Converting between them is exact arithmetic.
Other spaces describe color as people see it. CSS Color Module Level 4 defines CIE Lab and LCH, and OKLab and OKLCH, a newer space designed by Björn Ottosson in which equal steps look equally different. The tool converts through CIE XYZ using the matrices published in the specification, and adapts between the D65 and D50 white points with the Bradford method, as the specification does.
Wide-gamut spaces such as Display P3 hold colors that sRGB cannot show. When a color is outside sRGB, the tool reduces its OKLCH chroma until it fits, keeping lightness and hue, which is the gamut mapping CSS Color 4 recommends; or it clips each channel if you prefer. CMYK here is the simple formula without a printer profile, so use it as a starting point, not a print-ready value.
Contrast follows WCAG 2.2. Each color’s relative luminance is computed from its linear red, green and blue, and the ratio is the lighter luminance plus 0.05 divided by the darker plus 0.05, from 1:1 to 21:1. Normal text needs 4.5:1 for level AA and 7:1 for AAA; large text, and icons and controls, need 3:1. The W3C’s explanation defines large text as at least 18 point, or 14 point bold.
Worked example
The hex color #2563eb has red, green and blue bytes of 37, 99, 235. As HSL that is hsl(221.21 83.19% 53.33%), and as OKLCH it is oklch(54.61% 0.2152 262.88).
Its relative luminance is 0.1532 and white’s is 1.0000, so the contrast on white is (1.0000 + 0.05) ÷ (0.1532 + 0.05) = 5.16:1. That passes AA for normal text, which needs 4.5:1, but not AAA, which needs 7:1.
The closest color of the same hue that reaches 7:1 on white is #104cd3, at 7.00:1. The vivid green oklch(70% 0.4 145) is outside sRGB; mapped into sRGB it becomes #00c300.
Understanding the result, and common mistakes
- Outside sRGB
- The color is more saturated than standard screens can show. sRGB formats show the nearest color; Lab, OKLCH, Display P3 and XYZ keep the original.
- Nearest CSS name
- The named CSS color closest to yours, measured in OKLab. “CSS name” means an exact match.
- Closest colors that pass
- Your color made lighter or darker, with the same hue and chroma, just far enough to reach the ratio.
- Rounding a ratio up. 4.49:1 fails AA; the tool rounds down so it never shows a pass that is not one.
- Judging contrast by hue. Red on green can have almost no luminance contrast even though the hues differ.
- Using HSL lightness to compare colors. Yellow and blue at the same HSL lightness look very different; OKLCH lightness matches what people see.
- Treating the CMYK values as print-ready. Real printing depends on the printer, inks and paper.
Frequently asked questions
Which format should I use in CSS?
Hex and rgb() work everywhere. OKLCH is easiest to adjust by hand, because changing its lightness or chroma changes the color evenly, and modern browsers support it.
What is the difference between Lab and OKLab?
Both separate lightness from color. OKLab is newer and keeps hue more constant as colors get lighter or more saturated, which makes it better for palettes and gradients.
Does transparency affect contrast?
Yes. The tool paints a translucent color over the background first, then measures the result, as WCAG does.
Why do some formats show none for hue?
Grays have no hue. CSS writes the missing hue as none.
Is anything uploaded?
No. Conversion and contrast checks run in your browser.
Sources
- CSS Color Module Level 4World Wide Web Consortium · retrieved Nov 14, 2026
- Web Content Accessibility Guidelines (WCAG) 2.2World Wide Web Consortium · retrieved Nov 14, 2026
- Understanding Success Criterion 1.4.3: Contrast (Minimum)World Wide Web Consortium · retrieved Nov 14, 2026
- A perceptual color space for image processingBjörn Ottosson · retrieved Nov 14, 2026
About these results
- Conversion runs in your browser. Nothing you enter is sent anywhere.