Skip to content

RGB to HEX Color Converter

Free

Convert RGB or RGBA color values to HEX instantly. Enter rgb(255, 87, 51), get #FF5733. Free, runs in your browser, no signup.

convert rgb to hexrgb color to hex codergba to hex
All Color Tools

Settings guide

RGB value ranges:

ChannelMinMaxMeaning
R (Red)02550 = no red, 255 = full red
G (Green)02550 = no green, 255 = full green
B (Blue)02550 = no blue, 255 = full blue
A (Alpha)0.01.00 = transparent, 1 = opaque (CSS range)

Common RGB to HEX conversions:

  • ·rgb(0, 0, 0) → #000000 (black)
  • ·rgb(255, 255, 255) → #FFFFFF (white)
  • ·rgb(255, 0, 0) → #FF0000 (red)
  • ·rgb(0, 128, 0) → #008000 (green)
  • ·rgb(0, 0, 255) → #0000FF (blue)

Output format options:

  • ·Uppercase HEX (#FF5733) — convention in most design tools and CSS.
  • ·Lowercase HEX (#ff5733) — preferred by some linters and CSS-in-JS libraries.
  • ·Without # prefix (FF5733) — for APIs and systems that add the prefix themselves.

Format comparison

RGB vs HEX in CSS: Both work. HEX (#FF5733) is more compact. RGB (rgb(255, 87, 51)) is more readable for code review and makes partial color manipulation easier in JavaScript. RGBA is cleaner than 8-digit HEX for alpha values.

RGB vs HSL: RGB maps to screen hardware directly; HSL maps to human perception. Adjusting brightness in RGB means changing all three channels proportionally — in HSL you just change the L value. Choose the format your audience (browser, tool, or developer) expects.

RGB vs OKLCH: CSS Color Level 4 introduces OKLCH as a perceptually uniform alternative. A CSS custom property like color: oklch(70% 0.15 30) is easier to adjust than rgb(255, 87, 51). However, OKLCH has limited tooling support in 2025 — RGB and HEX remain the safe defaults for production CSS.

How it works

1

Enter RGB

Type R, G, B values (0–255 each). Add an optional Alpha (0–1) for RGBA.

2

Convert

Each channel is converted to a 2-digit HEX string. Alpha is scaled to 0–255 and appended for RGBA.

3

Copy

Click the HEX output to copy — with or without the # prefix, uppercase or lowercase.

About this format

RGB to HEX conversion is one of the most common color operations in web development. Design tools export colors as HEX (#FF5733). CSS accepts both, but HEX is shorter and more compact in stylesheets. When your JavaScript canvas code, server-side template, or design system produces RGB integer values, this converter gives you the HEX equivalent in one click.

The conversion works by taking each RGB channel (0–255), converting it to a two-digit hexadecimal string, and concatenating them with a # prefix. Red 255 → FF, Green 87 → 57, Blue 51 → 33 → #FF5733. Values below 16 are zero-padded to maintain the two-digit format (Red 9 → 09, not just 9).

RGBA values with an alpha channel convert to 8-digit HEX. The alpha is normalized from the 0–1 CSS range to the 0–255 integer range and appended as a hex pair. rgba(255, 87, 51, 0.5) → #FF57337F (7F = 127, approximately half of 255).

Frequently asked questions

How do I convert RGB to HEX manually?+
Take each RGB value (0–255), divide by 16 to get the first hex digit, take the remainder as the second digit. For example, Red 255: 255÷16=15 remainder 15, both digits are F → FF. Blue 51: 51÷16=3 remainder 3 → 33. Combined: #FF5733.
What happens if an RGB value is below 16 in HEX?+
Values below 16 produce a single hex digit, but HEX colors require two digits per channel. The value is zero-padded: 9 becomes 09, 10 becomes 0A, 15 becomes 0F. Without padding, #09000A would incorrectly become #90A.
How do I convert RGBA to HEX?+
Convert the RGB channels normally, then convert the alpha: multiply the CSS alpha (0–1) by 255 and round to the nearest integer, then convert to HEX. Alpha 0.5 → 0.5 × 255 = 127.5 → 128 → 80. Append to the 6-digit HEX: #FF573380.
Does HEX support transparency?+
Yes, via the 8-digit HEX format (#RRGGBBAA). The last two digits control opacity in the same 00–FF range as color channels. #FF573300 is fully transparent, #FF5733FF is fully opaque, #FF573380 is 50% transparent.
Is HEX or RGB better for CSS?+
For opaque colors, HEX is more compact (#FF5733 vs rgb(255, 87, 51)). For transparent colors, rgba() is more readable than 8-digit HEX. Both produce identical rendering — the choice is stylistic. Most CSS style guides pick one and apply it consistently.

Related tools and guides