Skip to content

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.

Preview

#ff7a59

#ff7a59 is rgb(255, 122, 89), hsl(12, 100%, 67%), oklch(72.9% 0.17 35.1)

HEX#ff7a59
RGBrgb(255, 122, 89)
HSLhsl(12, 100%, 67%)
OKLCHoklch(72.9% 0.17 35.1)
CMYKcmyk(0%, 52%, 65%, 0%)Uncalibrated estimate
Nearest namedcoralNot exact: coral is #ff7f50
On white2.56:1Contrast with #ffffff: fails AA
On black8.18:1Contrast with #000000: AAA

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.

FormatValueWhat the numbers are
HEX#ff7a59Red, green, blue as base-16 pairs, 00 to ff
RGBrgb(255, 122, 89)Red, green, blue from 0 to 255
HSLhsl(12, 100%, 67%)Hue angle, saturation, lightness
OKLCHoklch(72.9% 0.17 35.1)Perceptual lightness, chroma, hue angle
CMYKcmyk(0%, 52%, 65%, 0%)Ink percentages, estimated without a color profile
The same color, #ff7a59, in each notation this tool outputs

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.

ColorOn whiteOn black
#5959597.00:1 (AAA)2.99:1 (fails AA)
#7676764.54:1 (AA)4.62:1 (AA)
#9494943.03:1 (large text and UI only)6.92:1 (AA)
#663399 rebeccapurple8.40:1 (AAA)2.49:1 (fails AA)
#ff7a592.56:1 (fails AA)8.18:1 (AAA)
#ff0000 red3.99:1 (large text and UI only)5.25:1 (AA)
Contrast of sample colors against white and black

05 · Use cases

When to use the Color Picker & Converter

  1. 01

    Convert a hex code into rgb() or hsl() for a stylesheet

  2. 02

    Get the OKLCH equivalent of a hex color for use in Tailwind v4

  3. 03

    Find the CSS named color nearest to a hex value

  4. 04

    Check whether a color has enough contrast against white or black text

06 · Examples

Color Picker & Converter examples

#ff7a59

ex 01

rgb(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 05

Outside 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 06

rgba(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?

Hex with 3, 4, 6 or 8 digits (the # is optional), rgb() and rgba(), hsl() and hsla(), oklch(), and the 148 CSS color names, including both gray and grey spellings. The functions accept the comma form, rgb(255, 122, 89), and the space form with a slash for alpha, rgb(255 122 89 / 50%). Anything else shows an error and the last valid color stays on screen. If no field is focused, pasting anywhere on the page fills the input.

Is OKLCH lossless from sRGB?

Going from sRGB to OKLCH, yes. The other direction is not always possible: some OKLCH values lie outside sRGB and only wide-gamut displays can show them. When you enter one, the tool says so and shows the nearest sRGB color with the same lightness and hue, found by lowering chroma until it fits.

How accurate is the CMYK conversion?

It is an estimate. CMYK is device-dependent and a true conversion needs a color profile for the press and paper. The tool uses the simple profile-free formula, which is fine for a screen reference and not a substitute for a print-side conversion.

What does 'nearest named color' mean?

CSS defines 148 color names such as red, dodgerblue and lavenderblush. If your color is exactly one of them the row is labeled Named. Otherwise it is labeled Nearest named and shows the name with the smallest distance in the OKLab color space, along with that name's hex value so you can see the difference.

Which color format should I use in CSS?

Hex is fine for one-off static values and is the most portable. Use OKLCH for anything you generate a scale from, such as tints, shades and hover states, because equal lightness steps look equal to the eye. OKLCH has been supported in all major browsers since 2023.

How is the contrast ratio calculated?

The ratio is (L1 + 0.05) / (L2 + 0.05), where L is the relative luminance of the lighter and darker color. The result runs from 1:1 for identical colors to 21:1 for black on white. The tool shows your color against white and against black, rounded down to two decimals, with the WCAG level it reaches: 7:1 for AAA, 4.5:1 for AA body text, and 3:1 for large text (24px regular or 18.66px bold) and UI component boundaries.

Can hex codes include transparency?

Yes. Eight-digit hex adds an alpha byte, so #ff7a5980 is the same color at about 50% opacity, and four-digit shorthand (#f7a8) expands the same way three-digit shorthand does. The tool reads both and carries the alpha into the HEX, RGB, HSL and OKLCH rows. CMYK, the named color and the contrast ratios describe the opaque color.

08 · Guides

Color guides

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.

10 · More

Tools that pair with Color

Last updated .