RGB to HEX

Convert RGB colors to HEX as you type, with a live preview, the formula and a table of common colors converted.

loading RGB to HEX
About this tool

What are RGB and HEX?

RGB gives the same three sRGB channels as decimal numbers from 0 to 255, plus an optional alpha. HEX writes the red, green and blue channels of sRGB as two hexadecimal digits each, from 00 to FF.

Color pickers of screenshots, image editors and browser dev tools often show RGB; brand guides, Figma tokens and CSS variables usually keep HEX.

The color converter below starts from RGB and highlights HEX, next to HWB, LAB, LCH and CSS names.

RGB vs HEX

RGBHEX
Notationrgb(255 178 36), rgb(255, 178, 36)#RRGGBB, #RGB, #RRGGBBAA
In CSSall browsersall browsers
Typical usecode that computes colors, canvas, image librariesCSS, design handoff, brand guides

Formula

Write each channel (0–255) as two hexadecimal digits and join them: 255 → FF, 178 → B2 (178 = 11 × 16 + 2), 36 → 24, so rgb(255, 178, 36) is #FFB224. Values below 16 need a leading zero (10 → 0A).

What changes in the conversion

  • RGB and HEX describe the same sRGB color; the only difference is rounding of the last digit.
  • Transparency (alpha) is kept: #RRGGBBAA, rgb(… / 0.5), hsl(… / 50%) and oklch(… / 0.5) all carry it.

How to convert RGB to HEX

  1. Type or paste the RGB value in its line, or pick a color with the color picker.
  2. Read the HEX line, which updates as you type, and check the preview swatch.

Common colors from RGB to HEX

Converted with the same code as the tool:

ColorRGBHEX
amber (stdlib.tools accent)rgb(255, 178, 36)#FFB224
tealrgb(11, 114, 133)#0B7285
bluergb(59, 130, 246)#3B82F6
greenrgb(22, 163, 74)#16A34A
redrgb(220, 38, 38)#DC2626
mid grayrgb(128, 128, 128)#808080
blackrgb(0, 0, 0)#000000
whitergb(255, 255, 255)#FFFFFF

Frequently asked questions

Is RGB to HEX exact?

Yes, up to rounding: both describe the same 8-bit sRGB color, so converting back gives the same value.

Which format should I use in CSS?

HEX and rgb() work everywhere; hsl() is handy for shades written by hand; oklch() gives even lightness steps and wide-gamut colors in current browsers.

How do I write HEX with transparency?

Add two more digits for alpha: #FFB22480 is the amber at 50% opacity (80 hex = 128 of 255).

Report a problem