Skip to content
Colour Lab

Colour Converter

Convert hex to RGB, and between HSL, OKLCH, LAB, LCH and OKLAB, with a colour picker and every format shown at once.

  • #hex to rgb
  • #rgb to hex
  • #color code converter
  • #colour
  • #color
  • #hex
  • #rgb
  • #hsl
  • #oklch
  • #convert
100% client-side

Runs in your browser. Your data never leaves this device.

The Workbench
Colour Converter — workspaceLive
Enter a valid colour value to see conversions
HEX#3b82f6
RGB59, 130, 246
Decimal RGB0.2314, 0.5098, 0.9647
HSL217, 91%, 60%
LAB54.5 8.5 -65.5
LCH54.5 66.0 277.5
OKLAB0.64 -0.01 -0.15
OKLCH0.64 0.15 264
Network requests0
Bytes uploaded0
Trackers fired0
The Guide

About Colour Converter

/01 Converting a colour between notations

Enter a colour in any supported notation — hex, RGB, HSL, OKLCH, LAB, LCH or OKLAB — and read it back in all the others. Handy when a brand guide gives you one format, your design tool wants another, and your CSS uses a third.

Modern CSS accepts the perceptual spaces directly, so oklch() and lab() values can go straight into a stylesheet in current browsers.

/02 Why the perceptual spaces are worth knowing

HSL is convenient but lies about lightness: hsl(60 100% 50%) yellow and hsl(240 100% 50%) blue claim identical lightness while looking nothing alike. OKLCH and LAB are built so that equal numeric steps look like equal visual steps.

That makes them far better for generating tints and shades, building accessible palettes, and interpolating gradients without the muddy grey band you get halfway through an RGB blend.

/03 How hex to RGB conversion works

A hex colour code is just RGB written in base 16. The six digits split into three pairs for red, green and blue, and each pair runs from 00 to FF, which is 0 to 255 in decimal. Take #3B58E2: 3B is 3 × 16 + 11 = 59, 58 is 5 × 16 + 8 = 88, and E2 is 14 × 16 + 2 = 226, so the colour is rgb(59, 88, 226).

Two variations catch people out. Three-digit shorthand doubles each digit, so #F60 means #FF6600. Eight-digit hex adds a fourth pair for opacity: FF is solid, 80 is roughly 50 percent and 00 is invisible, so #3B58E280 is the same blue at half opacity. In modern CSS you can write that as rgb(59 88 226 / 50%).

Paste any of these forms in and the converter shows the colour in hex, RGB, HSL, OKLCH, LAB, LCH and OKLAB together, ready to copy.

FAQ

Questions about Colour Converter.

What is OKLCH and should I use it?
A perceptually uniform space using lightness, chroma and hue. It is supported in current browsers and is a better basis than HSL for generating consistent colour scales, because equal steps in lightness actually look equal.
Why does my colour shift when converting?
Some spaces describe colours that others cannot represent. A vivid OKLCH value can fall outside the sRGB gamut, so converting to hex clamps it to the nearest displayable colour.
Which notation should I put in my CSS?
Hex and RGB work everywhere. OKLCH is well supported in modern browsers and worth using when you want predictable lightness relationships across a palette.
How do I convert hex to RGB by hand?
Split the six digits into three pairs and convert each from base 16 to decimal. For #3B58E2, 3B is 59, 58 is 88 and E2 is 226, which gives rgb(59, 88, 226).
What does an 8-digit hex code mean?
The last two digits set opacity. FF is fully opaque, 80 is about 50 percent and 00 is fully transparent, so #3B58E280 is the same colour at half opacity.
Can I convert hex to Pantone?
Not exactly. Pantone colours are physical inks and many screen colours have no printable equivalent, so any hex to Pantone result is only a nearest match. Check it against a printed Pantone swatch book before approving print work.
Related
Contrast Checker

WCAG contrast checker: test any text and background colour pair against WCAG 2.1 AA and AAA ratios, with a live preview.

contrast checkerwcag contrastcolor contrast checker
Harmony Generator

Color harmony generator: build complementary, triadic, analogous, split-complementary, tetradic and monochromatic schemes from one colour.

color harmonycomplementary colorscolor wheel generator
Tailwind Shade Generator

Tailwind color palette generator: turn one colour into a full 50 to 950 shade scale, as a Tailwind config or CSS variables in hex or OKLCH.

tailwind color palettetailwind color generatortailwind shades
Gradient Generator

CSS gradient generator for linear, four-corner and mesh gradients with optional grain. Copy the CSS or export a PNG background.

gradient generatorcss gradientbackground gradient generator
Pixel Picker

Color picker from image: upload a photo or screenshot and sample the exact hex colour of any pixel with a magnified zoom loupe.

color picker from imagehex color from imageimage color picker
Palette Extractor

Color palette from image: extract dominant, vibrant, muted, warm or cool colours from any photo, with hex codes to copy.

color palette from imageextract colors from imageimage to color palette
Palette Generator

Color combination generator: create colour palettes from a seed colour with multiple strategies, lock colours you like, and export them.

color combination generatorcolor palette generatorcolor scheme generator
Palette Collection

Browse 284 curated color palettes across artistic, nature, vintage, modern, soft, bold, seasonal and monochrome styles, and copy any colour.

color palettescolor palette ideashex color palettes
Colour Blindness Simulator

Color blindness simulator: preview an image or colour as people with protanopia, deuteranopia, tritanopia and five other colour vision types see it.

color blindness simulatorcolor blind simulatorred green color blindness