Hex to RGB Converter
Convert any hex color code to its exact RGB values — the two most common ways developers write color in CSS and code — computed client-side with no rounding drift.
- Red (R)
- 255
- Green (G)
- 99
- Blue (B)
- 71
How it works
A 6-digit hex code is just RGB written in base 16: the first two characters are the red channel, the middle two green, the last two blue, each ranging from 00 to FF (0-255 in decimal). #FF6347 splits into FF (255), 63 (99), and 47 (71) — parse each pair as a base-16 integer and you have the RGB triplet directly, no intermediate math required, which is why hex-to-RGB is the one conversion in this whole toolkit that's exact rather than approximate. 3-digit shorthand (#F63) is expanded by duplicating each digit (F→FF, 6→66, 3→33) before parsing, per the CSS Color Module spec. Hex itself became the dominant color-authoring format on the web less because it's the most human-readable option and more because it was the format early browsers' HTML color attributes standardized on in the mid-1990s — RGB functional notation (rgb(255,99,71)) arrived slightly later in CSS1 as a more explicit alternative for the same underlying 24-bit value.
Worked example
#FF6347 (the CSS named color 'tomato') expands to RGB(255, 99, 71) — parse FF as 255, 63 as 99, 47 as 71. For the 3-digit shorthand #F00 (pure red shorthand), each digit doubles: F→FF (255), 0→00 (0), 0→00 (0), giving RGB(255, 0, 0), identical to the full 6-digit #FF0000. A mid-gray shows the pattern holding at low values too: #767676 splits into 76/76/76, each pair parsing to 118, giving RGB(118, 118, 118) — since all three channel pairs are identical, this is a fast visual check that a hex code represents a true neutral gray rather than a slightly tinted near-gray, which is easy to miss just by eyeballing a swatch on screen but obvious once the three RGB numbers are sitting side by side.
When to use this tool
This is the tool to reach for specifically when you're reading hex out of a design tool (Figma, Sketch, a browser DevTools color swatch) and need the RGB triplet for a codebase that expects rgb() or a canvas/graphics API that takes separate numeric channels rather than a hex string. It also comes up when debugging a rendering bug in a `<canvas>` or WebGL context, where APIs like `getImageData()` and shader uniforms work in raw RGB(A) numeric arrays rather than hex strings, so translating a designer-supplied hex value into the exact numbers a rendering call expects is a genuinely common step in graphics-adjacent debugging work, not just a design-handoff convenience. If you need every format at once rather than just RGB, the full Color Converter covers the same conversion plus five more formats in one page.
Precision & accuracy
Because hex and RGB encode the exact same 24-bit color data in two different number bases, this conversion is mathematically exact with zero rounding at any step — there's no floating-point arithmetic involved at all, just base conversion, which is a meaningfully different (and simpler, more trustworthy) guarantee than the other conversions on this site that do involve real floating-point math and therefore small rounding. This exactness is also why hex-to-RGB round-trips perfectly in both directions with no exceptions, unlike HSL or Lab conversions, where a hex → HSL → hex round-trip can occasionally land one integer off the original value at certain edge lightness levels due to the trigonometric functions involved in the HSL formula.
FAQ
Does this handle 3-digit hex shorthand?
Yes — #fff expands to #ffffff (each digit doubled) before conversion, matching the CSS spec's shorthand rule.
Does hex-to-RGB conversion lose any precision?
No — unlike HSL, Lab, or OKLCH conversions, hex and RGB are the exact same data in two different bases (hexadecimal vs. decimal), so there's no rounding involved in either direction.
What about 8-digit hex with alpha (#RRGGBBAA)?
The tool parses the alpha channel separately from the RGB channels and reports it as a 0-1 opacity value alongside the RGB triplet.
Does capitalization matter in the hex input?
No — hex digits are case-insensitive by spec, so #FF6347, #ff6347, and #Ff6347 all parse to the identical RGB triplet.
Can I paste a hex code without the leading #?
Yes — the parser accepts hex with or without the leading # symbol, so both 'FF6347' and '#FF6347' resolve identically.
Why do some old codebases write RGB as three separate CSS variables instead of one rgb() string?
Splitting RGB into separate --r/--g/--b custom properties lets a stylesheet reconstruct rgba(var(--r), var(--g), var(--b), var(--alpha)) with a variable alpha channel at runtime — a common pattern for dynamically adjustable opacity that a single hex or combined rgb() string can't support without JavaScript.