RGB to Hex Converter

Left pane: type six hex digits or paste rgb() / #RRGGBB. Right pane: sRGB swatch plus R, G, and B (0–255). Channels and #RRGGBB stay in sync—copy either form into CSS.

sRGB triples written as rgb() or #RRGGBB

On the web, an opaque color is three bytes in the sRGB space: red, green, and blue, each an integer from 0 through 255. CSS accepts that triple as rgb(r, g, b) or as six hexadecimal digits #RRGGBB—the same numbers, two notations.

Hex digits are base 16, which is why a channel such as 128 becomes 80. Confirm a single channel with the radix converter, sample a pixel with the color picker, and tidy a stylesheet with the CSS formatter.

Bytes, hex pairs, and the sRGB default

Why each RGB channel is a byte from 0 to 255

  1. One channel is an 8-bit unsigned integer: 256 levels, from no light (0) to full primary (255).
  2. The three channels are independent—changing green does not rescale red or blue.
  3. rgb(255, 128, 0) is full red, mid green, and zero blue in sRGB, not a print ink mix.
  4. Browsers treat plain rgb() and #RRGGBB as sRGB unless a wider space such as display-p3 is named.

How two hex digits encode one channel

  1. Base 16 uses 0–9 and A–F; two digits cover 0 through 255 exactly (16×16).
  2. The high digit is sixteens, the low digit is ones: 0x80 = 8×16+0 = 128.
  3. #RRGGBB concatenates the three pairs in red, green, blue order.
  4. Letter case does not change the value: #ff8000 and #FF8000 are the same triple.

Three-digit #RGB shorthand versus six digits

  1. CSS expands #RGB by repeating each digit: #F80 becomes #FF8800, not #F80000.
  2. That expansion is not the same as padding with zeros.
  3. Shorthand cannot express every 24-bit color—only values where each channel’s two digits match.
  4. Design tokens usually store the six-digit form so every byte is explicit.

What stays outside a plain RGB hex triple

  1. Alpha lives in rgba() or an extra #AARRGGBB / #RRGGBBAA pair—opacity is not a fourth sRGB primary.
  2. HSL and OKLCH describe hue and lightness; converting them to RGB is a different formula.
  3. CMYK and Display P3 are other spaces—the same hex digits can look different on a wide-gamut screen if the profile changes.
  4. A hex literal in source code is still sRGB bytes until a color-space function says otherwise.

Where the two notations meet

Brand specs and CSS variables

Style guides often print #RRGGBB while stylesheets mix rgb() in shadows and gradients—both name the same sRGB bytes.

Computed styles in DevTools

Browsers frequently show computed colors as rgb(). The hex form is the same triple packed into three bytes.

Frequently asked questions

How do I convert RGB to hex online?
Paste rgb(r, g, b) or edit the R, G, and B fields (0–255). The hex field updates in real time—copy #RRGGBB into CSS, JSON tokens, or Tailwind config. You can also start from a sample swatch on the page and adjust from there.
How do I convert hex color to RGB?
Enter six hex digits such as FF8000 or #FF8000. The tool outputs rgb(255, 128, 0) and keeps channels editable so you can nudge one value and see the new hex instantly.
How do I convert #RRGGBB to rgb() for CSS?
Paste the hex into the converter and copy the rgb() line into color, border-color, box-shadow, or gradient stops. Both forms are valid in CSS Color Level 3/4 for opaque sRGB colors.
Why do designers use hex while CSS allows rgb()?
They encode the same sRGB triple. Hex is compact in brand PDFs and eight-character tokens; rgb() makes it obvious which channel to lighten or darken in code reviews. Many teams store hex in design tools and convert to rgb() only when building themes programmatically.
What is sRGB and why does it matter?
sRGB is the default RGB space on the web. Unless you use color(display-p3 …) or similar, browsers interpret rgb() and #RRGGBB as sRGB. This converter assumes that default—what you see in a normal monitor preview matches typical CSS rendering.
Is #FF0000 the same as rgb(255, 0, 0)?
Yes—pure sRGB red. Hex letters may be upper or lower case; leading # is optional in many tools but CSS accepts both #FF0000 and #ff0000.
Does this tool support #RGB shorthand?
Type or paste six-digit hex or full rgb() for automatic sync. For three-digit shorthand (#F00), expand each character twice (#FF0000) or enter rgb(255,0,0)—the editor works on full channels.
Can I convert a single channel from decimal to hex?
Each pair in #RRGGBB is one channel. Decimal 10 becomes hex 0A (always two digits). Use the R/G/B fields to experiment; the combined hex updates as you edit any channel.

RGB ↔ hex reference

  • rgb(255, 255, 255)White — #FFFFFF
  • rgb(0, 0, 0)Black — #000000
  • rgb(255, 0, 0)Red — #FF0000
  • rgb(255, 128, 0)Orange — #FF8000
  • rgb(59, 130, 246)Blue (Tailwind blue-500) — #3B82F6
  • rgb(16, 185, 129)Emerald — #10B981
  • #6366F1Indigo — rgb(99, 102, 241)