Color Converter · ColorShift

Convert colors between HEX, RGB, HSL and OKLCH with a live preview.

Updated:

100% client-side

Preview

Formats

What the color converter does

The same color can be written in several different formats depending on where it's used — CSS, design tools and older software each favor different notations like HEX, RGB, HSL or the newer OKLCH. ColorShift is a converter that keeps all four formats in sync: change any one of them and the other three update instantly, so you never have to look up a conversion formula or manually recalculate a color by hand.

How to use the color converter

  1. Pick a color with the color picker, click Random, or type directly into any of the format fields (HEX, RGB, HSL, OKLCH).
  2. Watch the Preview swatch and the other three fields update automatically.
  3. Click the copy icon next to any field to copy that format.

How color conversion works

Every color format represents the same sRGB space in a different way. HEX and RGB are direct (base-16 vs. three 0-255 numbers); HSL describes color as hue/saturation/lightness; OKLCH uses a more modern perceptual model where lightness and hue changes feel uniform to the human eye:

#6C4FE0
→ rgb(108, 79, 224)
→ hsl(252, 70%, 59%)
→ oklch(54.2% 0.209 286.3)

HEX/RGB/HSL conversions use the standard color-conversion formulas; OKLCH is computed by passing through linear sRGB and OKLab per Björn Ottosson's specification — all the math runs in your browser, no external libraries.

Examples

Type in any of the four fields and the other three update. These conversions were produced by the tool:

Input              HEX       RGB                 HSL                  OKLCH
#1d5dea            #1d5dea   rgb(29, 93, 234)    hsl(221, 83%, 52%)   oklch(53.2% 0.222 262.9)
rgb(255, 99, 71)   #ff6347   rgb(255, 99, 71)    hsl(9, 100%, 64%)    oklch(69.6% 0.196 32.3)
hsl(150, 60%, 40%) #29a366   rgb(41, 163, 102)   hsl(150, 60%, 40%)   oklch(63.6% 0.140 156.1)
#fa0               #fa0      rgb(255, 170, 0)    hsl(40, 100%, 50%)   oklch(80.2% 0.171 73.3)

1. Brand blue to every format. A HEX value from a style guide becomes the rgb() you need for a canvas, the hsl() you want for a lighter hover shade, and the oklch() for a modern CSS palette.

2. A named-color value back to HEX. rgb(255, 99, 71) is CSS's tomato; its HEX is #ff6347.

3. Design in HSL, ship in HEX. Picking hue, saturation and lightness separately is easier than guessing hex digits: hsl(150, 60%, 40%) is #29a366. Three-digit shorthand works too — #fa0 is #ffaa00.

Common color-conversion pitfalls

  • Rounding in HSL. HSL here is shown in whole numbers, so converting HEX → HSL → HEX can land slightly off: #1d5dea shows as hsl(221, 83%, 52%), and typing that HSL back gives #1f5fea. Keep the HEX or RGB value as your source of truth and treat the HSL shown as a readable approximation.
  • Equal HSL lightness doesn't mean equal brightness. hsl(60, 100%, 50%) (yellow) looks far brighter than hsl(240, 100%, 50%) (blue) at the same 50%. OKLCH's first number is perceptual lightness, so two colors with the same L look about equally light — that is why it is the better space for building color scales.
  • Reading contrast from a converter. Converting formats doesn't tell you whether text is readable on a background. Check the pair in the Color Contrast Checker against the WCAG 4.5:1 minimum.
  • OKLCH colors outside sRGB. OKLCH can describe colors more saturated than an ordinary screen shows. If you edit the chroma by hand and push it high, browsers clip the color to the closest one they can display, so what you see may differ from the numbers.
  • Alpha and old syntax. Modern CSS writes rgb(29 93 234 / 50%) with spaces and a slash; the comma form rgba(29, 93, 234, 0.5) still works everywhere. Don't mix both styles in one function.

Color converter vs. other tools

Browser DevTools can cycle a color between formats: in Chrome, Shift+click the color swatch in the Styles panel. Design tools like Figma show HEX, RGB and HSL in their color picker. In code, libraries such as culori or chroma-js convert at build time. This page is the fastest way to get all four notations side by side — including OKLCH, which most pickers still don't show — and copy the one you need. The color spaces and syntax are defined in CSS Color Module Level 4. Once you have your colors, check readability with the Color Contrast Checker.

Frequently asked questions

What is OKLCH and why use it instead of HSL?

OKLCH is a perceptually uniform color space: changing lightness (L) or hue (H) doesn't distort perceived brightness the way it does in HSL. It's the format recommended by CSS Color Module Level 4 for consistent palettes.

Do all the formats update at the same time?

Yes. Editing any of the four fields (HEX, RGB, HSL or OKLCH) instantly recalculates the other three and the preview.

Does it support colors outside the sRGB space?

No; this tool works within sRGB (the standard display space), just like HEX and RGB. An OKLCH value outside that range gets clipped to the closest sRGB color.

What happens if I type an invalid value?

That field is marked in red and the others keep the last valid color until you fix the value.