Skip to content

Guides

HEX, RGB and HSL colour codes explained

Updated 21 October 2026

Tool for this guide: Colour converter

Short answer: HEX, RGB and HSL describe the same colour in different ways. Type any of them into the colour converter and you get all three, ready to copy as CSS, plus contrast checks against white and black.

The three formats

FormatExampleHow it works
HEX#1E90FFRed, green and blue as two hexadecimal digits each
RGBrgb(30, 144, 255)Red, green and blue from 0 to 255
HSLhsl(210, 100%, 56%)Hue (0–360°), saturation and lightness

#FF8000 is the same as rgb(255, 128, 0): FF = 255, 80 = 128, 00 = 0.

Why HSL is handy

HSL makes it easy to create variations of one colour: keep the hue, raise the lightness for a tint or lower it for a shade. That's how many design systems build a palette.

Transparency

Add an alpha value for transparency: 8-digit HEX (#1E90FF80), rgba(30, 144, 255, 0.5) or hsla(210, 100%, 56%, 0.5).

Contrast ratios (WCAG)

RatioPasses
4.5:1 or moreWCAG AA for normal text
3:1 or moreWCAG AA for large text (about 24 px, or 19 px bold)
7:1 or moreWCAG AAA for normal text

Step by step

  1. Open the colour converter.
  2. Type HEX, RGB or HSL, use a colour name, or pick a colour.
  3. Copy the code you need and check the contrast.

Find colours to convert

Questions

How do I convert HEX to RGB?

Type the HEX code, such as #1E90FF, and rgb(30, 144, 255) appears straight away.

Try it now

Type a colour in HEX, RGB or HSL, or pick one, and get every format ready to copy, plus contrast checks for text.

Open colour converter