Skip to content

Color converter for HEX, RGB, HSL and OKLCH.

Convert any CSS color between HEX, RGB, HSL, HSV, OKLCH and OKLab, and copy it as a ready-to-use CSS value.

  • On white

    5.88:1AA

  • On black

    3.57:1AA large text

#2f4bff, oklch(0.5265 0.2634 267.74).

HEX
#2f4bff
RGB
rgb(47 75 255)
HSL
hsl(231.9 100% 59.2%)
HSVNot CSS. For design tools
231.9°, 81.6%, 100%
OKLCH
oklch(0.5265 0.2634 267.74)
OKLab
oklab(0.5265 -0.0104 -0.2632)
Value format
--color-brand: oklch(0.5265 0.2634 267.74);

Free and private: this tool runs entirely in your browser.Need a design that converts? Talk to TechnoHelp

How to use the color converter

  1. Enter or pick a color

    Paste any CSS color, such as #2f4bff, rgb(47 75 255), hsl(232 100% 59%), oklch(0.53 0.26 268) or a name like tomato, or choose one with the color picker.

  2. Copy the format you need

    Every format updates as you type. Click the copy icon next to HEX, RGB, HSL, HSV, OKLCH or OKLab. Transparency is kept in every format that supports it.

  3. Make it a CSS variable

    Name your custom property, choose the value format and copy a line like --color-brand: oklch(…); straight into your stylesheet or design tokens.

  4. Check text contrast

    See the contrast ratio of your color as text on white and on black, then open it in the contrast checker to test it against your own background.

Color formats and when to use them.

HEX
#2f4bff

Red, green and blue as two hexadecimal digits each, from 00 to ff. Compact and supported everywhere, which makes it the usual choice for design handoff and brand guides. Add two more digits for transparency: #2f4bff80.

RGB
rgb(47 75 255 / 0.8)

The same sRGB values as HEX, written as numbers from 0 to 255. Easier to read than HEX and handy when you need an alpha value. The older comma syntax and rgba() still work.

HSL
hsl(231.9 100% 59.2%)

Hue angle, saturation and lightness. Good for quick tweaks by hand, like a slightly darker hover color. Its lightness is not perceptual, so different hues at the same HSL lightness can look very different in brightness.

HSV / HSB
231.9°, 81.6%, 100%

Hue, saturation and value (or brightness), the model behind many design tool color pickers. It is not a CSS function, so convert it to HEX, RGB or OKLCH before using it in code.

OKLCH
oklch(0.5265 0.2634 267.74)

Lightness, chroma and hue in the perceptual OKLab color space. Equal steps in lightness look like equal steps, which makes it the best fit for palettes, tints and shades, and design tokens. It can also describe colors beyond sRGB, such as those on Display P3 screens.

OKLab
oklab(0.5265 -0.0104 -0.2632)

The same space as OKLCH in rectangular form: lightness plus a green–red axis (a) and a blue–yellow axis (b). Useful for mixing colors and gradients that avoid muddy midpoints, for example with color-mix(in oklab, …).

All of these formats are defined in CSS Color Module Level 4, except HSV. In short: use HEX or RGB for broad compatibility, HSL for quick manual tweaks, and OKLCH when you are building a palette that needs to look even.

Reading OKLCH values.

OKLCH describes a color the way people tend to think about it: how light it is, how colorful it is, and which hue it is.

L, lightness
0 is black and 1 is white. You can also write it as a percentage, from 0% to 100%.
C, chroma
0 is gray. Higher is more colorful. In CSS, a chroma of 100% equals 0.4, and sRGB colors stay below it.
H, hue
An angle from 0 to 360 degrees. It is meaningless when chroma is 0, so grays show a hue of 0.
OKLCH lightness and hue of the pure sRGB primaries and secondaries
ColorHEXLightnessHue
Red#ff00000.62829.23
Yellow#ffff000.968109.77
Green#00ff000.8664142.5
Cyan#00ffff0.9054194.77
Blue#0000ff0.452264.05
Magenta#ff00ff0.7017328.36

HSL gives pure yellow and pure blue the same 50% lightness, yet in OKLCH yellow is 0.968 and blue is 0.452. That difference is why OKLCH palettes are easier to keep consistent.

Some OKLCH values have no sRGB equivalent. When that happens, this converter keeps your exact OKLCH value and shows the nearest sRGB color for HEX, RGB and HSL by lowering chroma, following the gamut mapping approach in CSS Color 4. oklch() works in all current major browsers. If you also support older ones, declare a HEX fallback first:

color: #2f4bff;
color: oklch(0.5265 0.2634 267.74);

OKLab and OKLCH were published by Björn Ottosson in 2020. His original article explains the math this tool uses.

Frequently asked questions.

How do I convert HEX to RGB?

Split the six digits into three pairs and convert each pair from base 16 to a number from 0 to 255. For #2f4bff, 2f is 47, 4b is 75 and ff is 255, so the color is rgb(47 75 255). This converter does it instantly for any color.

What is OKLCH, and why use it instead of HSL?

OKLCH is a CSS color format with lightness, chroma and hue values based on the perceptual OKLab color space. Unlike HSL, colors with the same OKLCH lightness look about equally light, so tints, shades and whole palettes stay consistent when you change the hue. It can also express colors beyond sRGB on wide-gamut screens.

Do all browsers support oklch()?

Yes, oklch() is supported in all current major browsers. If you need to support older browsers, declare a HEX or rgb() fallback first and the oklch() value after it. Browsers that don't understand oklch() ignore that line and keep the fallback.

What is the difference between HSL and HSV?

Both start with a hue angle. In HSL, lightness 100% is always white and 50% is the most saturated version of the hue. In HSV (also called HSB), value 100% with saturation 100% is the pure hue, and value 0% is black. HSV is common in design tool color pickers, but it is not a CSS function.

How do I add transparency to a HEX color?

Use eight digits: #rrggbbaa. The last pair sets opacity from 00 (fully transparent) to ff (fully opaque), so #2f4bff80 is about 50% opaque. You can also write rgb(47 75 255 / 50%) or add / 0.5 to hsl() and oklch().

Why does the converter say my color is outside the sRGB gamut?

OKLCH and OKLab can describe colors that HEX, RGB and HSL cannot, such as very saturated greens for Display P3 screens. The converter keeps your exact OKLCH and OKLab values, and shows the nearest sRGB color for the other formats by reducing chroma while keeping lightness and hue.

Is there a difference between rgb() and rgba()?

Not in modern CSS. In CSS Color Level 4, rgba() and hsla() are aliases of rgb() and hsl(), and all of them accept an optional alpha value. The space-separated form, rgb(47 75 255 / 0.5), is the current syntax.

Is this color converter free? Is my data stored?

Yes, it is free with no sign-up. Conversions run entirely in your browser, and your last color is saved only in your browser's local storage.

From the team behind these tools

Need a color system that scales with your product?

TechnoHelp is an independent web design and development studio. Our UI/UX team designs accessible color palettes and design tokens that stay consistent from mockup to code.

More free tools.

See all tools