Converters

RGB to HEX Converter

Convert any RGB triplet into an exact HEX color code. Enter red, green and blue values from 0 to 255, see the color preview update live, and copy the full HEX or its 3-digit short form in one click.

RGB input

Try an example:

#267D70
Live preview

HEX output

Full HEX (6 digits)

#267D70

Short HEX (3 digits, when possible)

— (not compressible)

The short 3-digit form is only valid when each hex pair is identical (e.g. #FFCC00 → #FC0).

How to convert RGB to HEX — the exact method

  1. Take each RGB channel value (0–255).
  2. Convert it to hexadecimal (base 16), padding to 2 digits if needed.
  3. Concatenate the three pairs and prefix with #.

Example: rgb(38, 125, 112) → 26, 7D, 70 → #267D70.

Quick RGB to HEX reference chart

ColorRGBHEXShort HEX
Red255, 0, 0#FF0000#F00
Green0, 255, 0#00FF00#0F0
Blue0, 0, 255#0000FF#00F
White255, 255, 255#FFFFFF#FFF
Black0, 0, 0#000000#000
Teal (brand)38, 125, 112#267D70—

Why use RGB to HEX conversion

RGB is how screens think — direct 8-bit channel values. HEX is how CSS and design tools usually store colors. Most design tools (Figma, Sketch, Adobe apps) let you enter either, but designers often need to convert one format to the other when working across tools, documentation, or legacy codebases.

When to prefer HEX vs RGB

  • HEX — small, compact and the CSS default. Use it in stylesheets, design tokens and brand guidelines.
  • RGB — clearer when working with alpha transparency or when manipulating channels programmatically.
  • HSL — better for adjusting lightness or saturation. Convert via our RGB to HSL Converter.
  • CMYK — for print. Convert via our CMYK Converter.

FAQ

How do I convert RGB to HEX?
Convert each channel (0–255) to a two-digit hex number and concatenate them after a #. rgb(38, 125, 112) = #267D70.
When can a HEX code be shortened to 3 digits?
When each pair of hex digits is identical. For example, #FFCC00 can be written #FC0. The tool detects that and shows the short form.
Does RGB to HEX lose precision?
No. Both formats carry 8 bits per channel, so whole-number RGB values convert exactly and reversibly.
Can I use the HEX output in CSS?
Yes. Any HEX value produced here is valid CSS.
What if I enter a value outside 0–255?
The tool warns you and refuses to convert until each channel is between 0 and 255.
Is the tool free and private?
Yes. Free, no signup, all processing in your browser. Nothing is uploaded.

Related tools

Related articles