RGB to OKLCH Converter — Modern CSS Color
Convert RGB to OKLCH for evenly-spaced colour ramps. Build accessible systems, but verify contrast separately—OKLCH lightness is not WCAG contrast.
- OKLCHoklch(0.5106 0.2301 276.97)
- HEX#4F46E5
- RGBrgb(79, 70, 229)
- HSLhsl(243, 75%, 59%)
- HSVhsv(243, 69%, 90%)
- CMYKcmyk(66%, 69%, 0%, 10%)
You're on 7BusyBoss — 300+ free tools that run instantly in your browser. No signup, nothing uploaded.
Building an accessible colour ramp starts with evenly-spaced lightness
Designers often build colour tokens—the 50/100/200…900 scales used throughout a design system—by holding hue and chroma constant and stepping lightness. OKLCH makes this work because its lightness (L) is perceptually uniform: stepping L by equal increments gives a ramp that actually looks evenly spaced, unlike HSL where some hues appear darker than others at the same stated lightness. This uniform stepping is why so many design tools now recommend OKLCH for building colour systems. This converter reports L and C to four decimal places and hue to two, which is ample resolution for defining token stops.
OKLCH lightness is not WCAG contrast, and that is the critical error
Here is the distinction that quietly breaks accessible colour ramps: OKLCH L and WCAG contrast ratio are completely different measurements, and one cannot stand in for the other. WCAG 2.x contrast is computed from linearised sRGB relative luminance — a weighted sum that treats green as far more luminous than blue — and then combined as (L1 + 0.05) / (L2 + 0.05). OKLCH lightness is a perceptual scale built on a different model entirely. The two curves do not track each other.
The practical consequences run in both directions. Two colours can sit a comfortable distance apart in OKLCH L and still fail 4.5:1. And two colours with identical OKLCH L can have different contrast ratios against the same background, because they differ in chroma and hue. A ramp that looks perfectly even is not thereby accessible, and an accessible pair is not thereby even-looking. These are two separate properties that happen to both involve the word "lightness".
Always check each pair against a real contrast ratio calculator
The working method is to use OKLCH to make the ramp look visually even, then measure every foreground/background pair you actually intend to use. Run them through the colour contrast checker and compare against the real thresholds: 4.5:1 for AA on body text, 3:1 for AA on large text (roughly 18pt, or 14pt bold), 7:1 for AAA on body text and 4.5:1 for AAA on large text. Non-text UI elements such as input borders and icons have their own 3:1 requirement. Measuring is not optional — visual evenness and accessible contrast are solved by different formulas and must be verified separately.
Chroma has no fixed ceiling, and the reachable maximum differs by hue
Unlike HSL saturation, which is always a percentage of some maximum, OKLCH chroma is an absolute distance with no built-in upper bound. The catch is that the highest chroma sRGB can actually display varies considerably by hue — a vivid green reaches about 0.29 while other hues top out well below that. So if you lock chroma and rotate through hues at constant lightness, some hues will fall outside the gamut while others sit comfortably inside, and the ones that fall outside get clamped on the way to a displayable colour.
The rule of thumb that follows: a lightness-locked ramp on a single hue is safe, because you are moving along an axis the gamut supports. A chroma-locked hue rotation is not, and will silently clip somewhere. If you need a full hue wheel at matched intensity, lower the chroma until the weakest hue in your set is comfortably inside the gamut, and accept that your strongest hues will be less vivid than they could be.
How to use the RGB to OKLCH Converter
Takes about a minute. No signup, no download, your data stays in your browser.
- 1Open the tool. Scroll up to the RGB to OKLCH Converter above — it loads instantly in your browser, no install needed.
- 2Enter your values. The fields come pre-filled with realistic defaults so you can see how it works — replace them with your own numbers.
- 3Read the result. The output updates instantly. Copy or share it — nothing is uploaded to a server, everything stays on your device.
Frequently asked questions
Common questions about the RGB to OKLCH Converter.
Why build color tokens in OKLCH instead of HSL?
OKLCH lightness is perceptually uniform, so stepping L by equal increments produces a ramp that looks evenly spaced across all hues. HSL lightness does not account for human perception, so yellow at L50 appears much brighter than blue at L50. For design systems where visual consistency matters, OKLCH delivers what your eyes actually see.
Can I use OKLCH lightness gaps to ensure WCAG contrast compliance?
No. OKLCH lightness and WCAG contrast are calculated from completely different formulas, so neither predicts the other. Two colours can be well separated in OKLCH L and still fail 4.5:1, and two colours with identical L can score differently against the same background. Verify every foreground and background pair with an actual contrast checker.
What contrast ratios do I actually need to hit?
For WCAG AA, body text needs 4.5:1 and large text needs 3:1, where large means roughly 18pt or 14pt bold. For AAA the same two cases become 7:1 and 4.5:1. Non-text elements such as input borders, focus rings and meaningful icons need 3:1. Check each pair you intend to ship rather than assuming a ramp is safe throughout.
Can converting RGB to OKLCH push a colour out of gamut?
No. An RGB value is inside sRGB by definition, so the OKLCH you get back from one is always displayable. Gamut trouble only starts if you then raise the chroma by hand, or hold a chroma fixed while rotating the hue, since the reachable maximum differs by hue. Converting a hand-authored out-of-range value back clamps each channel independently, which can shift the hue as well as the intensity.
What precision does this tool use for OKLCH output?
L and C are rounded to four decimal places and hue to two. That is a display choice rather than a limit of the maths, and it is far finer than any screen or eye can resolve. As a concrete example, rgb(59, 130, 246) converts to oklch(0.6231 0.188 259.81), and pure green rgb(0, 255, 0) to oklch(0.8664 0.2948 142.5).
Community rating
Discussion (0)
No comments yet. Start the discussion.
Keep exploring
Related tools across 7BusyBoss — all free, all instant.