b2KIT

CSS Color Function Converter

Convert between CSS color formats: hex, rgb, hsl, hwb, oklch, oklab, and color() with live swatch.

Tested tool guide Tested browser tools Checked August 16, 2026

What CSS Color Function Converter does and how it behaves

CSS Color Function Converter takes a color written as hex, rgb(), hsl(), hwb(), oklab(), oklch(), or color() and expresses that color in the other supported CSS forms. It resolves the entered components as a color, displays the converted coordinates, and provides a live swatch for visual checking. The common surprise is that equivalent colors do not retain similar-looking numbers: HSL, HWB, OKLab, and OKLCH describe color through different coordinate systems, so their component values are not directly comparable.

How the result is produced

1

Parsing the color

The converter first interprets the entry according to its CSS notation. Hex and rgb() describe sRGB channel values, hsl() uses hue, saturation, and lightness, and hwb() uses hue, whiteness, and blackness. OKLab and OKLCH use perceptual coordinates. A color() value also identifies the color space associated with its components.

2

Changing coordinates

Conversion changes the coordinates used to describe a color, not the intended color itself. Rectangular OKLab coordinates use L, a, and b, while OKLCH expresses the same model with lightness, chroma, and hue. Decimal rounding can make a converted value slightly different after repeated conversions. The swatch helps reveal differences large enough to be visible.

Good uses

  • Convert a design token supplied as hex into OKLCH before editing its lightness or chroma.
  • Translate an hsl() value into rgb() or hex for a stylesheet convention that requires sRGB notation.
  • Inspect how a color() value is represented by the tool's other supported CSS color functions.

Limits and checks

  • Equivalent-looking output is not textually interchangeable component by component; each notation assigns different meanings and ranges to its numbers.
  • Hex and rgb() represent sRGB colors. A source color outside the sRGB gamut cannot be preserved exactly in those target forms.
  • The live swatch is not a contrast, accessibility, or cross-display test. Background, transparency, color management, and display gamut can affect appearance.

Common questions

Will every converted format render exactly the same color?

For a color inside the target gamut and output with sufficient precision, the formats should describe the same color closely. No, exact visual identity is not guaranteed in every case. Rounded coordinates can introduce small differences, and a target such as hex cannot preserve a source color that lies outside sRGB. Display capabilities can also change what the swatch shows.

Can I compare HSL lightness directly with OKLCH lightness?

No. HSL lightness and OKLCH lightness belong to different color models and do not have equivalent numeric meanings. Matching their displayed percentages or decimals does not ensure matching appearance. Use the conversion result to preserve a color between formats, but use a dedicated contrast calculation when the actual question is text readability or accessibility.

References and verification

The behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools