HEX to RGB Converter
Turn any #hex code into its RGB values instantly, with a live color swatch.
Need the opposite? RGB to HEX
This HEX to RGB converter takes a hex color code, like #1a73e8 or the short form #f60, and gives you the equivalent RGB values the moment you type it. A live swatch shows the actual color, so you can confirm you grabbed the right code before it goes into your stylesheet.
The classic reason to convert this way is CSS. You have a hex code from a brand guide or an existing stylesheet, but you need rgb() or rgba() syntax, usually because you want transparency: rgba(26, 115, 232, 0.5) needs the three RGB numbers that hide inside #1a73e8. Canvas APIs, some JavaScript libraries and older email clients also want colors as separate red, green and blue channels.
The conversion runs locally in your browser and updates as you type. Nothing is sent to a server, there is nothing to install, and both 3-digit and 6-digit hex codes work, with or without the leading #.
How to convert HEX to RGB
- Type or paste a hex code into the input, for example #ff6600 or just f60.
- The RGB values appear instantly, alongside a preview swatch of the color.
- Check the swatch matches the color you expected.
- Copy the rgb() string with the copy button, ready to paste into CSS.
- Need the reverse? Use the RGB to HEX converter linked on this page.
What this HEX to RGB converter does
The tool reads a hex color code and returns the same color written as three decimal channels: red, green and blue, each from 0 to 255. You get the raw numbers plus a ready-to-paste rgb() string and a live swatch, so there is no manual arithmetic and no jumping into a calculator to work out what ff or 66 means in base ten.
It is deliberately narrow. It does one job, converting hex to RGB, and does it the instant you type, entirely in your browser. That focus is also why it handles the awkward variants you actually meet in real files: 3-digit shorthand, an optional leading #, upper or lower case, and 8-digit codes that carry an alpha channel.
How the math works
A hex code is three pairs of hexadecimal digits: red, green, blue. Each pair converts to a decimal number from 0 to 255. So #ff6600 splits into ff, 66 and 00, which are 255, 102 and 0, giving rgb(255, 102, 0). Short codes duplicate each digit first: #f60 expands to #ff6600.
Hex and RGB describe exactly the same color in the same sRGB space, so the conversion is lossless in both directions. #RRGGBB is simply base-16 notation for the very same channel values, which is why converting hex to RGB is exact math with no rounding and no color shift; which notation you use is purely about what the syntax around it expects.
When you actually need RGB
The everyday trigger is transparency. A hex code from a brand guide gives you an opaque color, but the moment you want it at 50% you need the channels: rgba(26, 115, 232, 0.5), or the modern rgb(26 115 232 / 50%) syntax, both of which want the three numbers hiding inside #1a73e8. Converting first is faster and less error-prone than eyeballing it.
Beyond CSS, the HTML canvas API, many charting and animation libraries, SVG attributes and some older email clients expect colors as separate red, green and blue values. If you are handing a color to JavaScript that then tweaks a single channel, RGB is the format you can actually do arithmetic on.
The alpha channel and 8-digit hex
An 8-digit hex code adds a fourth pair for opacity: #1a73e880. The first six digits convert to RGB exactly as usual, and the final pair maps the range 00 to ff onto an alpha of 0 to 1. So 80 in hex is 128 in decimal, which is roughly 0.5 opacity, giving rgba(26, 115, 232, 0.5).
This matters because designers increasingly paste 8-digit codes exported from Figma or Sketch. Treat the color and the transparency as two separate facts: the RGB triple never changes when you adjust opacity, only that trailing alpha pair does.
RGB and color accessibility
Web accessibility guidelines set contrast ratios between text and its background, and the formulas behind them work on RGB channel values, not on the hex string. Converting your hex code to RGB is the first step to checking whether, say, #767676 text clears the 4.5:1 threshold on a white background for normal body copy.
Because the conversion is exact, the RGB numbers you get here are safe to drop straight into a contrast checker or into code that computes relative luminance. If a color is borderline, nudging one channel in RGB and converting back is an easy way to find a compliant near-match without abandoning the brand hue.
Common mistakes to avoid
The usual slip is a malformed code: a 4 or 5 character string, a stray space, or a # left in when a tool wanted the bare digits. Valid hex is 3, 6 or 8 hex characters; anything else is either shorthand to expand or simply invalid. This converter is tolerant of case and the leading #, but the underlying color still has to be well formed.
The other trap is assuming hex is somehow lower quality than RGB, or vice versa. They are identical sRGB colors written two ways. If a converted color looks off, the problem is almost always that the source code was wrong, not that the conversion introduced error.
Related color tools
Going the other direction is just as common, so pair this with the RGB to HEX converter when a design app or eyedropper hands you plain channel numbers you need as a compact hex token. Both are exact and both run locally.
If you are still choosing a color rather than converting a fixed one, the color picker lets you drag to a shade and read its HEX, RGB and HSL at once, and the CSS gradient generator builds copy-ready linear and radial backgrounds from the colors you land on.
Frequently asked questions
Is this hex to RGB converter free?
Yes, free and unlimited. No sign-up, and the conversion happens in your browser with no data sent anywhere.
Why would I need RGB instead of hex in CSS?
Mostly for transparency. rgba() and the modern rgb(r g b / alpha) syntax need the individual channel numbers. Hex has an alpha form (#RRGGBBAA), but rgba() is still more widely used and easier to read.
Do 3-digit hex codes like #f60 work?
Yes. Shorthand codes are expanded by doubling each digit, so #f60 is treated as #ff6600, exactly as browsers do it.
Does converting hex to RGB change the color?
No. Hex and RGB are two notations for the same sRGB values, so the conversion is exact, with no rounding and no color shift.
What about 8-digit hex codes with alpha?
An 8-digit code like #1a73e880 carries a fourth pair for opacity. The first six digits convert to RGB as usual; the last pair maps 00-ff to an alpha of 0 to 1, giving you an rgba() value.
Does it work on mobile?
Yes. The converter is a lightweight page that works in any phone browser, handy when you are reading hex codes out of a style guide on the go.