HEX to RGB
Convert HEX colour codes to rgb() values.
rgb(0, 229, 255)
How to use HEX to RGB
What is a HEX colour?
A hex colour is a six-digit number written in base-16 (hexadecimal)
that encodes the red, green and blue intensity of an sRGB colour. The
first pair of digits is the red channel, the middle pair the green
channel, the last pair the blue channel — each from 00 (none) to
FF (255, full). So #FF0000 is pure red, #00FF00 pure green,
#0000FF pure blue, and #FFFFFF is the sum of all three channels
at full strength: white. Hex notation has been the dominant way to
write colours in HTML and CSS since the format was introduced in 1996
because it’s compact, deterministic and trivial to copy between tools.
What is the rgb() function?
rgb() is the canonical CSS functional notation for an sRGB colour,
written with three decimal channel values from 0 to 255 — for example
rgb(255, 0, 0) for red. It’s exactly the same colour space as hex,
just expressed in decimal instead of hexadecimal. Where hex is more
common in design files and final stylesheets, rgb() is easier to
generate programmatically (it’s just three numbers in a string) and
plays nicely with CSS custom properties, JavaScript and design-token
systems that store channel values as integers.
The conversion math
Each pair of hex digits is a base-16 number in the range 00–FF.
Convert it to decimal: FF = 15 × 16 + 15 = 255, 1A = 1 × 16 + 10 = 26, B0 = 11 × 16 + 0 = 176. So #1AB0FF becomes
rgb(26, 176, 255). The three-digit shortcut #abc doubles each
digit before this step: #abc → #aabbcc → rgb(170, 187, 204). The
converter does this in a few lines of JavaScript — no library
required.
Use cases
CSS authoring. Sometimes you want the rgb() form in your
stylesheet because you’ll be tweaking alpha later (a CSS preprocessor
can turn rgb(0, 229, 255) into rgba(0, 229, 255, 0.5) more
naturally than a six-digit hex), or because your design-token system
emits decimal triplets.
JavaScript and canvas work. Canvas’s fillStyle, strokeStyle
and most colour-handling libraries accept rgb() strings or decimal
channel values directly. Converting a hex from a Figma export into
the three decimals you need to pass to ctx.fillStyle = ... is the
single most common reason developers reach for this conversion.
Accessibility and contrast work. Most WCAG contrast calculators take rgb() values; converting designer-supplied hex into rgb() is the first step in plugging a colour into a contrast tool.
Email and legacy systems. Some HTML email clients are stricter
about rgb() than hex (or vice-versa). When debugging a colour that
isn’t rendering, swapping notation is a quick sanity check.
Pitfalls
- Hex is sRGB only. The converter assumes the input is sRGB (the default colour space of the web). Wide-gamut hex (display-p3 hex isn’t a thing) and CMYK hex strings (these are sometimes invented in print-design contexts but aren’t standard) aren’t supported.
- Alpha is not preserved. Eight-digit hex (
#RRGGBBAA) loses the alpha channel here — use the HEX to RGBA landing. - Named colours not accepted.
red,blue,dodgerblueand the 148 other CSS named colours aren’t parsed by this landing; use the Color Name Finder to get a hex first.
How to use this HEX to RGB converter
- Paste your hex colour into the input. It can have a leading
#or not, and can be six or three digits, uppercase or lowercase. - The
rgb(r, g, b)output and the colour swatch update live — there is no Convert button. - If your input isn’t a valid hex (wrong length, contains non-hex characters, missing digits), a friendly inline message says what’s wrong without consuming a click.
- Tap Copy to put the rgb() string on your clipboard.
Privacy
Conversion is a five-line function running in your browser tab. No server is involved at any point. The page caches its small JavaScript bundle and from then on works fully offline.
Compatibility notes
The output is standard CSS rgb() notation supported by every
browser since the 1990s. If you need the modern slash-separated
syntax (rgb(255 0 0 / 0.5)), the Color Converter offers it; this
landing emits the classic comma-separated form because that’s still
the most widely compatible and the form most CSS linters accept by
default.
Frequently asked questions
What hex formats does this accept?
#RRGGBB (six hex digits) and the shorthand #RGB (three hex digits — each character is treated as if doubled, so #F0A means #FF00AA). The leading # is optional. Hex is case-insensitive: #ff00aa, #FF00AA and #FF00aa all produce the same RGB output. Anything else — four-digit hex with alpha, named CSS colours, rgb() strings — should be entered into the related tools (hex-to-rgba for alpha, or the full Color Converter for everything else).Why does my short hex like #fff produce 255,255,255 (white)?
#fff expands to #ffffff, where ff in hex is 255 in decimal. So #fff is rgb(255, 255, 255) — pure white. The same rule means #f00 is #ff0000 (full red, 255,0,0) and #abc is #aabbcc (light blue). It's a useful shortcut when each pair of hex digits is the same; for everything else use the six-digit form.Will the converter handle uppercase or lowercase hex?
0–9, a–f and A–F are all valid digits and the parser treats them identically. Most design tools (Figma, Photoshop, Sketch) emit uppercase hex (#0B1020); browser DevTools, CSS conventions and Tailwind tokens often use lowercase (#0b1020). Paste either; the converter accepts both.I need rgba() with an alpha channel — what should I use?
rgb(r, g, b) — three channels only, no alpha. Eight-digit hex like #0B1020CC (the trailing CC is alpha) needs a tool that understands the alpha digits, which the HEX to RGBA landing handles. For round-tripping, the Color Converter handles every format together with a live preview.Is my colour data uploaded anywhere?
Related tools
RGB to HEX
Convert rgb() colours to HEX codes.
HEX to RGBA
Convert HEX (including 8-digit hex-with-alpha) to rgba().
HEX to HSL
Convert HEX colours to hsl() values for tints and shades.
Color Converter
Convert colors between HEX, RGB, HSL, HSV, and CMYK.
WCAG Contrast Checker
Check color contrast against WCAG AA and AAA.
RGBA to HEX Converter
Convert RGBA colors into 8-digit HEX with alpha.