Skip to the tool

HEX to RGB converter

Paste a HEX code, read the RGB, or the other way round. The maths is two-digit base sixteen, and it is written out below for the day you need to do it by hand.

Guide

How to use it

  1. Paste or type the HEX code into the HEX field, with or without the #.
  2. Read the RGB (and HSL) instantly from the fields below it, both stay in sync as you type.
  3. Copy the format you need with its button.
  4. Typing RGB converts the other way, HEX updates live.

Examples

The conversion, worked

#FF6600 → 255, 102, 0

Split into pairs: FF, 66, 00. Each pair is base-16: FF = 15×16 + 15 = 255, 66 = 6×16 + 6 = 102, 00 = 0. That is the whole trick.

46 → 2E

Reverse: divide by 16. 46 ÷ 16 = 2 remainder 14, and 14 is E in hex, so 46 becomes 2E. Digits above 9 borrow letters: A=10 through F=15.

#333 = #333333

Three-digit HEX doubles each digit: #333 expands to #333333, rgb(51, 51, 51). Shorthand only exists when all three pairs are twins.

Method

How it works

A HEX colour is three bytes written in base sixteen: two digits each for red, green and blue, each pair running 00 to FF (0 to 255). Converting is positional arithmetic, first digit times sixteen plus the second, done per channel.

The converter also derives HSL, which restates the same colour as hue, saturation and lightness. Nothing about the colour changes across formats, only the notation.

FAQ

Frequently asked questions

Is #FFFFFF white or black?

White, all three channels at maximum light. #000000, all channels off, is black. Screens add light, unlike paint.

What does the # actually do?

It is CSS marking the token as a colour literal. The value is the six digits, the # is punctuation, this converter accepts both.

What about 8-digit HEX like #2E6B98CC?

The extra pair is alpha (opacity), CC ≈ 80%. This tool works with the solid six digits, opacity is a property of where the colour is used.

Why do developers prefer HEX?

Compactness and copy-paste culture. RGB wins when a program computes channels, HSL wins when a human adjusts them, they are interchangeable notations.

Are HEX colours the same on every screen?

The numbers are, the perception is not: uncalibrated displays shift colours. For brand-critical work, that is a monitor problem, not a notation problem.

Can I convert a whole palette?

One at a time here, each conversion is instant and the recent swatches keep the set together as you work through it.

More tools

Related tools

Color pickerThe full picker with eyedropper and contrast. Image color pickerGet the HEX of a pixel in a photo. Colour pickerUK spelling, same tool. Base64 encoderMore developer conversions.
Skip to the tool

HEX to RGB converter

Paste a HEX code, read the RGB, or the other way round. The maths is two-digit base sixteen, and it is written out below for the day you need to do it by hand.

#2e6b98

Drag on the square, slide the hue, or type any value.

HEX
RGB
HSL
Contrast (WCAG)
on white 5.72:1 on black 3.30:1

Body text needs 4.5:1. As text, this colour passes on white and fails on black.

All colour maths happens in your browser. Images you sample from are never uploaded.

Guide

How to use it

  1. Paste or type the HEX code into the HEX field, with or without the #.
  2. Read the RGB (and HSL) instantly from the fields below it, both stay in sync as you type.
  3. Copy the format you need with its button.
  4. Typing RGB converts the other way, HEX updates live.

Examples

The conversion, worked

#FF6600 → 255, 102, 0

Split into pairs: FF, 66, 00. Each pair is base-16: FF = 15×16 + 15 = 255, 66 = 6×16 + 6 = 102, 00 = 0. That is the whole trick.

46 → 2E

Reverse: divide by 16. 46 ÷ 16 = 2 remainder 14, and 14 is E in hex, so 46 becomes 2E. Digits above 9 borrow letters: A=10 through F=15.

#333 = #333333

Three-digit HEX doubles each digit: #333 expands to #333333, rgb(51, 51, 51). Shorthand only exists when all three pairs are twins.

Method

How it works

A HEX colour is three bytes written in base sixteen: two digits each for red, green and blue, each pair running 00 to FF (0 to 255). Converting is positional arithmetic, first digit times sixteen plus the second, done per channel.

The converter also derives HSL, which restates the same colour as hue, saturation and lightness. Nothing about the colour changes across formats, only the notation.

FAQ

Frequently asked questions

Is #FFFFFF white or black?

White, all three channels at maximum light. #000000, all channels off, is black. Screens add light, unlike paint.

What does the # actually do?

It is CSS marking the token as a colour literal. The value is the six digits, the # is punctuation, this converter accepts both.

What about 8-digit HEX like #2E6B98CC?

The extra pair is alpha (opacity), CC ≈ 80%. This tool works with the solid six digits, opacity is a property of where the colour is used.

Why do developers prefer HEX?

Compactness and copy-paste culture. RGB wins when a program computes channels, HSL wins when a human adjusts them, they are interchangeable notations.

Are HEX colours the same on every screen?

The numbers are, the perception is not: uncalibrated displays shift colours. For brand-critical work, that is a monitor problem, not a notation problem.

Can I convert a whole palette?

One at a time here, each conversion is instant and the recent swatches keep the set together as you work through it.

More tools

Related tools