Skip to content

Colour Converter - HEX, RGB, HSL & OKLCH Converter

Paste any CSS colour into any field: hex (3, 4, 6 or 8 digits), rgb(), rgba(), hsl(), hsla(), oklch() or oklab(), with commas or the modern space syntax.

Convert between CSS colour formats

Type or paste a colour into any field and the others update as you type: HEX, RGB, HSL, OKLCH and OKLAB, all with alpha. The swatch sits on a checkerboard so you can see transparency. Use the colour picker or the alpha slider to adjust, and the Copy button beside each field to copy it.

What you can paste

Every field reads every format, so oklch(70% 0.15 250) pasted into the HEX box still works. Legacy comma syntax (rgba(59, 130, 246, 0.5)) and modern space syntax (rgb(59 130 246 / 50%)) both parse, as do percentages, decimals and the hue units deg, rad, grad and turn. Named colours such as tomato are not recognised; paste the hex instead.

Example

Input #3b82f680 (blue at 50% opacity) gives:

HEX    #3b82f680
RGB    rgba(59, 130, 246, 0.502)
HSL    hsla(217.2, 91.2%, 59.8%, 0.502)
OKLCH  oklch(62.31% 0.188 259.81 / 0.502)
OKLAB  oklab(62.31% -0.0332 -0.1851 / 0.502)

The alpha is 0.502 rather than 0.5 because the hex byte 80 is 128/255. Use 7f (0.498) or write the alpha in rgb() if you need an exact half.

Which format to use in CSS

HEX is the usual handoff format from design tools. RGB is handy when a value comes from JavaScript or canvas pixel data. HSL is easy to adjust by hand. For design tokens and shade scales, oklch() is the better choice: two colours with the same L have similar contrast against white, which HSL cannot promise.

Related Tools

Frequently Asked Questions

How do I convert HEX to RGB?
Split the six digits into three pairs and read each pair as a base-16 number. #3b82f6 is 3b, 82 and f6, which are 59, 130 and 246, so rgb(59, 130, 246). Paste the hex into any field here and the RGB, HSL, OKLCH and OKLAB values appear straight away.
What do 3, 4 and 8-digit hex codes mean?
A 3-digit code doubles each digit: #f0c is #ff00cc. A 4-digit code adds a shorthand alpha digit. An 8-digit code such as #3b82f680 adds a full alpha byte; 80 is 128 out of 255, or about 50% opacity. All four lengths work here, with or without the #.
When should I use HSL?
When you want to tweak a colour by hand. Changing only L gives lighter or darker versions, lowering S greys it out, and changing H rotates the hue. The catch is that HSL lightness does not match how bright colours look: hsl(60 100% 50%) yellow and hsl(240 100% 50%) blue share 50% lightness, but their OKLCH lightness is 96.8% and 45.2%.
What is OKLCH and why use it?
A CSS colour format with lightness, chroma (how colourful) and hue, built on the OKLab colour space. Equal lightness values look equally bright, which makes it better than HSL for shade scales and contrast. Tailwind CSS v4 defines its palette in oklch(), and all current browsers support oklch() and oklab().
What happens if an OKLCH colour is outside sRGB?
OKLCH can describe colours a normal sRGB screen cannot show. The converter keeps the lightness and hue and lowers the chroma until the colour fits, the approach CSS Color 4 recommends. oklch(70% 0.4 150) is mapped to #00be58, which is oklch(70% 0.1928 149.99).
Why are my values slightly different from another tool?
Rounding. This converter keeps full precision internally, shows RGB as whole numbers, HSL to one decimal place and OKLCH to four decimals for chroma. Another tool that rounds at a different step may be off by one in a channel, which you will not see.