StatGardenREF. DESK
Calculators/Conversion/Hex to RGB Colour Converter
Conversion

Hex to RGB Colour Converter calculator

Converts a hex colour code to its RGB values, or RGB values to a hex code, both directions.

Published 21 August 2026

What this calculator does

A hex colour code such as #3B82F6 packs three numbers into six characters: the first two digits are red, the next two are green, and the last two are blue, each read as a base-16 (hexadecimal) number from 00 to FF. RGB expresses the same colour as three plain base-10 numbers from 0 to 255 instead.

This calculator converts hex to RGB or RGB to hex, both directions. Design tools, CSS and image editors tend to favour one format or the other, so switching between them comes up constantly when matching a colour across different software.

The formula

FormulaR = first byte, G = second byte, B = third byte of the hex value, each read as a base-16 number 0-255

For hex to RGB, the six-digit hex code is split into three two-digit pairs (or, for a three-digit shorthand like #39F, each digit is doubled first) and each pair is read as a base-16 number to get a value from 0 to 255. For RGB to hex, each of the three 0-255 values is converted to a two-digit base-16 number and the three are joined with a leading #.

TermMeaning
Hex colour codeA six-digit (or three-digit shorthand) base-16 number, prefixed with #, that encodes red, green and blue in one string.
RGBThe same colour expressed as three separate base-10 numbers, each from 0 to 255, for red, green and blue.
Base-16 (hexadecimal)A number system using 16 digits, 0-9 then A-F, where FF equals 255 in base-10.

The inputs explained

FieldWhat to enter
ConvertChoose whether to convert a hex code to RGB, or RGB values to a hex code.
Hex colour (e.g. #3B82F6)The hex colour to convert, with or without the leading #. Accepts either the 6-digit or 3-digit shorthand form.
Red (0-255)Red value, 0 to 255, used only when converting RGB to hex.
Green (0-255)Green value, 0 to 255, used only when converting RGB to hex.
Blue (0-255)Blue value, 0 to 255, used only when converting RGB to hex.

When to use it

Matching a brand colour across CSS and a design tool

A brand colour supplied as a hex code from a style guide converts to RGB for a tool or codebase that expects rgb() values, or the other way around.

Reading a colour picked from an image

An image editor or colour picker that reports RGB values converts to a hex code for use directly in CSS or HTML.

Checking a colour value pasted from an unfamiliar source

A hex or RGB value copied from a design file or website converts to the other format to confirm exactly which colour it represents before using it.

Worked examples

Every figure in the tables below is produced by this page’s own calculator at build time, so the numbers and the tool always agree. Select any row to load that scenario.

Hex to RGB for a few reference colours

A handful of pure and commonly used colours, converted from hex to RGB.

Common hex codes converted to RGB
Hex colourRGB
#000000rgb(0, 0, 0)
#FFFFFFrgb(255, 255, 255)
#FF0000rgb(255, 0, 0)
#00FF00rgb(0, 255, 0)
#0000FFrgb(0, 0, 255)
#3B82F6rgb(59, 130, 246)
Black (#000000) is red 0, green 0, blue 0, and white (#FFFFFF) is 255 across all three; the pure red, green and blue codes each max out one channel and zero the other two.

Questions

How do I convert hex to RGB?

Split the six-digit hex code into three two-digit pairs and read each as a base-16 number. For example, #3B82F6 splits into 3B, 82 and F6, which are 59, 130 and 246 in base-10, giving rgb(59, 130, 246).

What does a 3-digit hex code like #39F mean?

It is shorthand: each digit is doubled to make the full 6-digit code, so #39F expands to #3399FF.

What is white and black in RGB?

White is rgb(255, 255, 255) and #FFFFFF in hex. Black is rgb(0, 0, 0) and #000000 in hex.

Can I convert RGB back to hex with this calculator?

Yes. Choose "RGB to hex" and enter red, green and blue values from 0 to 255; the calculator returns the equivalent 6-digit hex code.

For converting a number between binary, decimal, hex and other bases directly, see the number base converter.