RGB Color Coordinates

Interactive EyeDropper / Palette:
0-255
0-255
0-255
Quick Color Presets

Hexadecimal Output

Contrast: High
HEX Code #2563EB
Full HEX
#2563EB
Short HEX
N/A
CSS RGB
rgb(37, 99, 235)
CSS HSL
hsl(221, 83%, 53%)

RGB to Hex Converter

Enter red, green and blue values between 0 and 255 and this tool returns the matching 6-digit hex code, ready to drop into CSS, Figma or any design tool that expects hex.

What's actually happening when you convert RGB to hex

Take RGB(255, 99, 71), a common tomato red. Hex just rewrites those same three numbers in base 16 instead of base 10, so the color itself doesn't change, only how it's written.

Convert each number separately. 255 becomes FF, 99 becomes 63, and 71 becomes 47. Stack them together with a leading # and you get #FF6347.

Why hex and RGB are the same color, just written differently

Unlike the jump from RGB to CMYK, converting RGB to hex loses nothing. Both formats describe the exact same red, green and blue light mixture, hex is simply a shorter way to write it that fits neatly into a single CSS property.

That's why you'll see both used interchangeably in code. Some developers prefer RGB because it's easier to read the individual channel values at a glance, others prefer hex because it pastes in as one compact string.

The base 16 conversion, step by step

  1. Split each RGB value into how many times 16 fits into it, and the remainder.
  2. Convert both numbers into a hex digit, 0 through 9, then A through F for 10 through 15.
  3. Combine the two digits for each channel, then join red, green and blue into one 6-character code.
Channel Decimal Hex
Red 255 FF
Green 99 63
Blue 71 47

Result: #FF6347

Where you'll use this

  • Writing CSS or inline styles when a design system already specifies RGB values
  • Matching a color picked from an image, since many editors show RGB, to a hex code for a website
  • Handing off brand colors between a designer working in RGB sliders and a developer who needs hex
  • Checking that a color someone gave you in RGB matches what's already in your codebase as hex

A note on color spaces

This conversion assumes standard sRGB, the color space almost every website, browser and phone screen uses by default. If you're pulling RGB values from a professional camera or a wide-gamut monitor set to Adobe RGB or DCI-P3, the same three numbers can render as a visibly different color once they hit a standard web page.

For everyday web and app design this rarely matters. It's only worth checking when a brand color needs to look identical across a print catalog, a native app and a website, in that case confirm which color space each output is actually rendering in before assuming the numbers alone are enough.

FAQ

Does RGB to hex ever lose accuracy?

No, assuming both are read in the same color space. Hex is just RGB written in base 16, so converting between them is exact, not an approximation like RGB to CMYK.

Can hex codes represent transparency?

A standard 6-digit hex code can't. For transparency, use an 8-digit hex code with an added alpha channel, or switch to RGBA, which adds a fourth value for opacity.

Why do some hex codes have only 3 digits?

That's the shorthand form, where each digit repeats once. #F00 expands to #FF0000. It only works when both digits in each pair match, so most real-world colors need the full 6-digit version.

Is hex or RGB better for CSS?

Both work the same way in a browser. Hex is more compact and common in style guides, RGB or rgba is more readable when you need to adjust one channel or add transparency.

How do I go the other direction, from hex to RGB?

Use our hex to RGB converter, or reverse the steps here: split the hex into three pairs and convert each pair from base 16 back to decimal.