Tool guide
About this tool.
CSS can write the same color in many ways. Hex (#3b82f6) and rgb() give red, green and blue channels; hsl() and hwb() use a hue with saturation and lightness, or whiteness and blackness; lab(), lch(), oklab() and oklch() describe perceived lightness, chroma and hue.
The converter accepts every CSS Color 4 notation, including space-separated channels with / alpha, percentages, hue units and the 148 named colors, and writes all the others. OKLCH is the easiest to adjust by hand: change L to lighten or darken, C for intensity and H for hue.
Colors from lab(), lch(), oklab() or oklch() that fall outside sRGB are brought into range by reducing chroma, as browsers do, and a note says so.
- Move a design token from hex to oklch() to build lighter and darker variants in even steps.
- Translate a color from a design tool, a stylesheet or a brand guide into the notation your code base uses.
- Check whether white or black text reads better on a brand color before using it as a background.
Paste a color in any CSS notation, or a color name. The result updates as you type.
Choose Commas for rgb(59, 130, 246) style or Spaces for CSS Color 4 style such as rgb(59 130 246 / 50%).
Check the swatch and the contrast ratios; the suggested text color is the one with more contrast.
Copy the notation you need. For palettes and shades, continue in Color Palette & Contrast.
- #3b82f6 → rgb(59, 130, 246), hsl(217.2, 91.2%, 59.8%) and oklch(62.31% 0.188 259.81).
- #3b82f680 → rgba(59, 130, 246, 0.502); hex keeps the 80 alpha byte.
- rgb(59 130 246 / 50%) → the same blue with alpha 0.5; Spaces output keeps this syntax.
- rebeccapurple → #663399, and name shows the CSS name.
- #10b981 → closest named color: mediumseagreen (ΔE 2.3).
- oklch(70% 0.4 150) → outside sRGB, so chroma is reduced and a note explains it.
- #ff0000 → 4:1 contrast on white and 5.25:1 on black, so black text is suggested.
- Conversion is local and follows the CSS Color 4 math that browsers use: sRGB, OKLab with a D65 white point and CIE Lab with D50.
- rgb() channels are rounded to whole numbers and hex to two digits per channel, so a round trip through hex can shift the other notations slightly.
- CMYK is a simple device conversion without an ICC profile; print shops convert differently.
- Contrast ratios follow WCAG 2: 4.5:1 for normal text and 3:1 for large text. Transparent colors are composited over white or black first.
- Hue is written as none for grays, where it has no meaning.
- color(display-p3 …), other wide-gamut spaces and relative color syntax are not supported yet.
- The closest named color is measured in OKLab (ΔE × 100); below about 2 the difference is hard to see.