Convert RGB to HEX

Convert RGB color values to HEX codes instantly. Enter R, G, B values (0-255) and get the hex code. Free online tool.

Formula: HEX = # + R.toString(16) + G.toString(16) + B.toString(16)

Quick example: rgb(37, 99, 235) → #2563EB

Color Preview
#2563EB
Color Values
#
HEX
R
RGB
H
HSL
C
CMYK84%, 58%, 0%, 8%
A
Alpha
100%
T
Tailwind
blue-600#2563ebclose match
WCAG Contrast Checker
Foreground#2563eb
Background#ffffff
Contrast Ratio
5.17:1
Sample Text Preview
AA Large: PassAA Normal: PassAAA: Fail
Analogous Palette

About This Conversion

Converting RGB values to HEX is one of the most common tasks in frontend development. RGB values (0-255 for each channel) are converted by transforming each decimal value to its two-digit hexadecimal equivalent and concatenating them with a # prefix. This conversion is needed when design tools export colors as RGB but your CSS uses hex notation, when generating color values programmatically, or when you need the compact hex format for configuration files, brand guidelines, or design tokens.

Frequently Asked Questions

How do I convert RGB to HEX?
Convert each RGB value (0-255) to hexadecimal (00-FF) and concatenate: rgb(255, 128, 0) → FF=255, 80=128, 00=0 → #FF8000.
Why do some hex codes have 3 digits instead of 6?
Shorthand hex (#RGB) doubles each digit: #F00 = #FF0000. This only works when both digits in each pair are the same (FF, 00, AA, etc.).
Do uppercase and lowercase hex codes differ?
No. #ff5733 and #FF5733 are identical in CSS. Convention varies by team — both are valid.

Related Color Conversions