Skip to content

Color converter

Convert between HEX, RGB, HSL, HWB and OKLCH, and check contrast.

Updated

AaAa

On white

3.68:1

WCAG AA Large

On black

5.71:1

WCAG AA

HEX
#3b82f6
RGB
rgb(59, 130, 246)
HSL
hsl(217.2, 91.2%, 59.8%)
HWB
hwb(217.2 23.1% 3.5%)
OKLCH
oklch(62.31% 0.188 259.81)

How to convert a color

  1. Type or paste a color in any format: #3b82f6, rgb(59 130 246), hsl(217 91% 60%) or oklch(62% 0.19 260).
  2. Or pick one with the color picker.
  3. Copy the format you need; every value is valid CSS.
  4. Check the contrast ratios before using the color for text.

Which color format should I use?

FormatDescribes a color byBest for
HEXRed, green, blue in hexadecimalSharing colors, design tools
RGBRed, green, blue from 0 to 255Screens, image editing, code
HSLHue, saturation, lightnessQuick tweaks: “a bit lighter”
HWBHue, whiteness, blacknessMixing tints and shades by hand
OKLCHPerceived lightness, chroma, hueDesign systems, even color scales

Contrast and accessibility

The WCAG contrast ratio compares how light two colors are, from 1:1 (identical) to 21:1 (black on white). Body text needs at least 4.5:1 to pass level AA, or 7:1 for AAA. Large text (about 24 px, or 19 px bold) and icons need 3:1.

Common uses

  • A brand color in every format. A brand guide gives a HEX code, but your CSS or design tool wants RGB or HSL. Paste it once and copy whichever format you need.
  • Checking text will be readable. Before using a color for text or buttons, check its contrast on white and on black against the WCAG AA and AAA levels.
  • Moving a palette to OKLCH. Convert existing HEX or RGB colors to oklch() when building evenly spaced shades for a design system in modern CSS.

Questions

How do I convert HEX to RGB?

Split the six digits into three pairs and read each pair as a hexadecimal number from 0 to 255: #3b82f6 is 3b = 59 red, 82 = 130 green, f6 = 246 blue. Paste any HEX code above and the tool does it instantly.

What is OKLCH and why use it?

OKLCH describes a color by lightness, chroma (colorfulness) and hue, in a way that matches how people see. Changing only the lightness gives shades that look evenly spaced, which makes it great for design systems. All modern browsers support oklch() in CSS.

What do the contrast ratios mean?

They follow the WCAG accessibility guidelines. Normal text needs at least 4.5:1 against its background (AA), 7:1 for the stricter AAA level; large text needs 3:1.

Why was my color “clipped”?

Some OKLCH colors are more vivid than standard sRGB screens can show. The tool shows the closest displayable color and tells you when that happened.

All converters →