free tool, no sign-up

HEX to RGB Converter

Convert RGB values to a hex color code, or a hex code to red, green, and blue.

Six digits, or three-digit shorthand. The # is optional.

Red, green, and blue

Each channel is a whole number from 0 to 255.

HEX

#3B82F6

rgb()

rgb(59, 130, 246)

Red

59

Green

130

Blue

246

Examples

This HEX to RGB converter turns a hex color code into red, green, and blue values and writes RGB numbers back as a hex code. A code can be #RRGGBB, the same digits without a hash, or the three-digit shorthand #RGB, which expands by repeating each digit. The swatch, the rgb() value, and the separate channels update together, and each channel stays between 0 and 255. Students use it when a slide, a stylesheet, or an art program asks for the other form of the same color.

Hex digits and the 0 to 255 range

A hex color code stores red, green, and blue as three pairs of base-16 digits. #FF0000 means red is FF (255) and green and blue are 00, which is the same color as rgb(255, 0, 0).

The shorthand #RGB repeats each digit, so #fff is #FFFFFF and #f80 is #FF8800. To convert RGB to hex, write each channel from 0 to 255 as two hex digits: 59, 130, and 246 become #3B82F6.

Frequently Asked Questions

How do you convert RGB to hex?

Turn each of red, green, and blue into a two-digit hexadecimal number, then join them after a hash. 59 is 3B, 130 is 82, and 246 is F6, so rgb(59, 130, 246) is the hex code #3B82F6.

How does the shorthand #RGB work?

Three-digit hex repeats every digit instead of adding zeros. #fff becomes #FFFFFF, #000 becomes #000000, and #f80 becomes #FF8800. #fff is white, rgb(255, 255, 255).

What ranges do hex and RGB use?

Each channel is a whole number from 0 to 255. In hex that is 00 through FF. 0 means none of that color and 255, written FF, means the full amount.

What is #FF0000 in RGB?

#FF0000 is rgb(255, 0, 0): red 255, green 0, and blue 0. #3B82F6 is rgb(59, 130, 246), and the shorthand #fff is rgb(255, 255, 255).

Related Tools