RGB to HEX Converter

Convert an RGB color (0–255 each) to its #RRGGBB hex code.

Result

HEX color

#8A2BE2

How it works

Each channel → 2 hex digits, joined as #RRGGBB

A hex colour is the same information as RGB, written in base 16. Each channel — red, green, blue — runs from 0 to 255, which fits exactly two hex digits (00 to FF), and the three pairs are glued together as #RRGGBB. So rgb(255, 0, 128) becomes #FF0080: FF is 255, 00 is zero, 80 is 128. Two digits per channel give 256 values each, and 256³ = about 16.7 million possible colours — the "true colour" of every modern screen. A few landmarks make hex readable at a glance: #000000 is black, #FFFFFF white, and any code with three identical pairs (#808080, #CCCCCC) is a pure grey, because equal amounts of red, green and blue always produce grey. Hex won on the web because it is compact, unambiguous and copy-pasteable — a single token instead of three numbers.

Advertisement

Frequently asked questions

Why use hex colors?

Hex is compact and universal in CSS and design tools; #FFFFFF is white, #000000 is black.

What is the range per channel?

0 to 255, which maps to 00–FF in hexadecimal for each of red, green and blue.

What does a 3-character code like #F0A mean?

It is CSS shorthand: each digit is doubled. #F0A expands to #FF00AA, and #FFF to #FFFFFF. It only works when both digits of every channel are identical.

Advertisement

Related calculators