← All tools

Color Converter — HEX, RGB, HSL, OKLCH

Convert any CSS colour between HEX, RGB, HSL, HWB, OKLCH and CMYK, find its name and check text contrast.

Free tool No account
White text5.46:1 · AA
Black text3.84:1 · AA large text

Contrast uses WCAG 2: 4.5:1 for normal text (AA), 3:1 for large text, 7:1 for AAA. White text reads better on this colour.

ReadyProcessed locally · No upload
Enjoying Color Converter — HEX, RGB, HSL, OKLCH?Your review and ideas shape what we build next.

Review Color Converter — HEX, RGB, HSL, OKLCH

Please don't include file contents or passwords.

About the Color Converter — HEX, RGB, HSL, OKLCH

Type or pick a colour in any CSS format and get it in every other one: HEX, RGB, HSL, HWB, OKLCH and CMYK. The tool also tells you the colour's CSS name (or the closest one) and checks how readable white and black text are on it, using the WCAG contrast rules.

How to use it

  1. Type a colour, such as #3158f5, rgb(49 88 245), hsl(229 91% 58%), oklch(54% 0.24 267) or a name like tomato, or use the colour picker.
  2. Every format appears below, along with a large swatch.
  3. Click a format to copy it.
  4. Read the two contrast tiles to see whether white or black text is easier to read on this colour.

Tip: Paste straight from your stylesheet: a trailing semicolon, capital letters, the old comma syntax and the newer space syntax with / for transparency all work.

Colour formats explained

HEX (#3158f5)
Red, green and blue as two hex digits each, from 00 to ff. The short form #fff means #ffffff, and a fourth pair (#3158f580) adds transparency.
RGB (rgb(49, 88, 245))
The same three channels as numbers from 0 to 255. rgba() or a / alpha value adds transparency from 0 (invisible) to 1 (solid).
HSL (hsl(228, 91%, 58%))
Hue (0–360° around the colour wheel), saturation and lightness. The easiest format to tweak by hand: change only the lightness for a lighter or darker shade.
HWB (hwb(228 19% 4%))
Hue plus how much white and black are mixed in. Close to how painters think about tints and shades.
OKLCH (oklch(53.8% 0.238 266.8))
Lightness, chroma (colourfulness) and hue in a space built to match human vision. Two colours with the same L really look equally light, which HSL can't promise.
CMYK (cmyk(80%, 64%, 0%, 4%))
Cyan, magenta, yellow and black ink, as used in print. This is a simple conversion; for professional printing, use your printer's colour profile.

Which format should you use?

For websites, any of them works in modern browsers. HEX is the shortest and the most common in design files. HSL is handy when you build a palette by changing one number. OKLCH is the best choice for design systems, because steps in lightness look even and you can reach brighter colours on modern screens.

Keep HEX or RGB when you need the widest support, such as in HTML emails or older apps.

Contrast and accessibility

Text needs enough contrast with its background for everyone to read it, including people with low vision and anyone using a phone in sunlight. The WCAG 2 guidelines measure contrast as a ratio from 1:1 (no difference) to 21:1 (black on white).

4.5:1: AA
The minimum for normal body text.
3:1: AA large text
Enough for large text (about 24px, or 19px bold) and for icons and borders.
7:1: AAA
The stricter level, best for long reading.

How to build a palette from one colour

1. Start with your brand colour
Paste it and copy the HSL or OKLCH value.
2. Make lighter and darker steps
Change only the lightness: for example 95%, 85%, 70%, 55%, 40%, 25%. Keep hue and chroma the same.
3. Check text contrast for each step
Paste each step back in and use the tile that passes AA for buttons and text.
4. Add a muted version
Lower the saturation (HSL) or chroma (OKLCH) for backgrounds and borders.

CSS colour names

CSS has 148 named colours, from aliceblue to yellowgreen; the tool reads all of them. When your colour is exactly one of them you see its name; otherwise you get the closest name, measured in OKLCH so it matches what your eye sees. Names are handy for quick prototypes and for describing a colour in words.

RGB vs CMYK: screen and print

Screens mix red, green and blue light, starting from black; printers mix cyan, magenta, yellow and black ink on white paper. Some bright screen colours, such as pure #00ff00 green, can't be printed, so they look duller on paper. Use the CMYK values as a starting point and ask for a printed proof for anything important, like a logo or packaging.

Tips and tricks

Gray from any colour

Set saturation to 0% in HSL (or chroma to 0 in OKLCH) for a neutral gray with the same lightness.

Transparent overlays

Add a fourth hex pair or / 0.5 to any format: #00000080 is black at about 50%.

Out-of-range colours

Very colourful OKLCH values can be outside what most screens show (sRGB). The tool tells you and shows the nearest colour it can display.

Hover states

Make a button 5–10% darker in lightness for hover and a little more for pressed.

Questions

How do I convert HEX to RGB?

Paste the HEX code, for example #3158f5, and copy the RGB line: rgb(49, 88, 245). Each pair of hex digits is one channel: 31 = 49, 58 = 88, f5 = 245.

Why does my HSL value change slightly after converting?

HSL is rounded to whole numbers, and RGB has only 256 steps per channel, so converting back and forth can move a value by one. The colour on screen is the same.

What is OKLCH and why are designers switching to it?

OKLCH describes colours the way people see them, so equal steps in lightness look equal and hue changes don't shift brightness. All modern browsers support it in CSS.

Is the contrast check the same as WCAG?

Yes. It uses the WCAG 2 relative luminance formula and the AA and AAA thresholds. The check uses the colour without transparency.

Can I use colour names in CSS?

Yes. All 148 names, such as tomato, steelblue and rebeccapurple, work anywhere a colour is allowed. They are fixed sRGB colours, the same in every browser.

Is anything I type uploaded?

No. The tool runs in your browser; what you type or paste never leaves your device and nothing is stored on a server.

Related tools

Updated