HEX vs RGB vs HSL vs CMYK: Colour Codes Explained

The same blue can be written as #3D63E6, rgb(61, 99, 230) or hsl(227, 77%, 57%). Designers, developers and printers each use different colour formats, and switching between them is a daily task. Here is what each format means and when to use it.

Free tool
Convert colour codes
Convert between HEX, RGB, HSL and CMYK, get tints and shades, and check WCAG contrast against white and black. Free.
Open Color Converter →

The four formats at a glance

FormatExampleUsed for
HEX#3D63E6Web design, CSS, brand guidelines
RGBrgb(61, 99, 230)Screens, CSS, design tools
HSLhsl(227, 77%, 57%)CSS, creating colour variations
CMYK74, 57, 0, 10Print

HEX

A HEX code is RGB written in hexadecimal: two characters each for red, green and blue, from 00 to FF. #FFFFFF is white, #000000 is black. A short form like #FA0 means #FFAA00. An 8-digit HEX such as #3D63E680 adds transparency.

RGB

RGB mixes red, green and blue light, each from 0 to 255. Screens create every colour this way. In CSS, rgb(61 99 230 / 50%) adds 50% transparency.

HSL

HSL describes colour the way people think about it:

  • Hue – the colour on the colour wheel, 0–360° (0 red, 120 green, 240 blue)
  • Saturation – how intense, 0–100%
  • Lightness – from black (0%) to white (100%)

HSL makes it easy to create lighter and darker versions: keep hue and saturation, change lightness. Perfect for hover states and colour palettes.

CMYK

CMYK (cyan, magenta, yellow, black) is for printing with ink. Screen colours are brighter than many inks can reproduce, so bright blues and greens may look duller in print. Converting RGB to CMYK without the printer’s colour profile is only an approximation – ask your printer for their profile for brand-critical work.

Colour contrast and accessibility

Text must stand out from its background. The WCAG guidelines set minimum contrast ratios:

LevelNormal textLarge text (18 pt, or 14 pt bold)
AA4.5:13:1
AAA7:14.5:1

Our Color Converter shows the contrast of any colour against white and black so you can pick readable text colours.

Tips for brand colours

  • Store each brand colour in HEX, RGB and CMYK in your brand guide.
  • Create tints (lighter) and shades (darker) for backgrounds and hover states.
  • Test buttons and text for contrast before launch.
  • Use the same colours in your app icon, OG images and website.

FAQ

What is the difference between HEX and RGB?

They describe the same colour. HEX is RGB written in hexadecimal.

Which colour format should I use in CSS?

Any works. HEX is most common; HSL is handy for creating variations.

Why does my printed colour look different?

Print uses CMYK inks, which cannot reproduce every screen colour. Use your printer’s colour profile.

What contrast ratio do I need for text?

At least 4.5:1 for normal text and 3:1 for large text (WCAG AA).

Can HEX codes include transparency?

Yes, with 8 digits – the last two set the opacity.

Free tool
Try the free Color Converter
No signup and nothing uploaded – it runs right in your browser. Browse all 74 free tools on our Free Tools page.
Open Color Converter →

Need a website or app for your business? Talk to Techpass Master – we design and build websites and apps for clients worldwide.

WhatsApp us📞 Call now