How this instrument works
A six-digit hex color code packs three separate numbers into one string: two digits for red, two for green, two for blue, each pair an integer from 0 to 255 written in base 16 instead of base 10. Converting hex to RGB just reverses that packing. Take #4CAF50: split it into the pairs 4C, AF and 50, then read each pair as a base-16 number -- 4C is 4x16+12 = 76, AF is 10x16+15 = 175, and 50 is 5x16+0 = 80. The result, RGB(76, 175, 80), is the exact same color as #4CAF50, just written with three decimal numbers instead of one hex string.
CSS also allows a three-digit shorthand, like #4A5, wherever a color's six digits happen to repeat in pairs. To decode it, each digit is doubled before the usual math runs: 4 becomes 44, A becomes AA, 5 becomes 55, giving the full #44AA55 before splitting into bytes. That shorthand exists purely for shorter code -- #FFF and #FFFFFF describe the identical white, and a hex code is read the same way whether or not it starts with a # symbol, since the symbol is a CSS convention rather than part of the number itself.
This converter is scoped to CSS-style RGB hex color codes specifically -- three or six hex digits describing red, green and blue channel bytes. It does not accept the four- or eight-digit forms (#RGBA or #RRGGBBAA) that add a transparency channel; those need a separate alpha-aware step this tool doesn't perform. It's also a different tool entirely from hex-to-text converters, which decode a string of hex byte pairs into UTF-8 text characters -- those parse the same base-16 pairs but interpret each byte as a letter rather than a color channel, a completely different kind of hex string.
- Type or paste a hex color code into the Hex color code (hex) field, with or without a leading # -- #4CAF50, 4CAF50 and #FFF are all accepted.
- The converter splits the code into its red, green and blue byte pairs automatically, doubling each digit first if you entered the three-digit shorthand form.
- Read the Red (0-255), Green (0-255) and Blue (0-255) fields for the decoded channel values -- each is a whole number between 0 and 255.
- Use those three numbers anywhere RGB is expected: an rgb(76, 175, 80) CSS value, a design tool's RGB sliders, or a graphics library's pixel-color constructor.
- Stick to three- or six-digit hex codes -- this converter reads the standard #RGB and #RRGGBB color forms, not the four- or eight-digit forms that add transparency.
Worked example — a brand's #4CAF50 green as RGB
A designer hands off a brand guide listing the primary accent color as #4CAF50, but the charting library being used only accepts colors as separate red, green and blue numbers, not a hex string. Splitting #4CAF50 into byte pairs gives 4C, AF and 50. Converting 4C from base 16: 4x16 + 12 = 76 (the letter C is the hex digit for 12). Converting AF: 10x16 + 15 = 175 (A is 10, F is 15). Converting 50: 5x16 + 0 = 80.
The three results -- 76, 175, 80 -- are entered into the library's RGB fields as rgb(76, 175, 80), and the rendered color matches the brand guide's swatch exactly, because hex and RGB are two notations for the identical underlying byte values, with zero rounding at any step of the conversion in either direction.
Questions
Does hex-to-RGB conversion round any values, or lose precision?
No -- it's an exact base conversion, not an approximation. Each two-digit hex pair maps to exactly one integer from 0 to 255 with nothing left over, since 16x16 = 256 covers that full range precisely. Converting a color to hex and back to RGB, or the reverse, always returns the identical numbers it started from.
Does this tool accept the 3-digit shorthand, like #4A5?
Yes. CSS's three-digit shorthand is valid wherever each channel's two hex digits happen to repeat, and this converter expands it automatically before decoding: #4A5 becomes #44AA55 by doubling each digit, which then decodes to RGB(68, 170, 85). It only works for colors where that repetition actually holds -- a code like #4CAF50 has no valid shorthand form because its digit pairs (4C, AF, 50) don't repeat a single digit.
Do I need to type the # symbol before the hex code?
No -- the # is a CSS convention marking a hex color literal in a stylesheet, not part of the underlying number, so this converter reads 4CAF50 and #4CAF50 identically. Include it if you're copying directly from CSS, or leave it off if you're working from a hex string in another context; either way decodes to the same RGB(76, 175, 80).
Can this tool decode hex colors with a transparency channel, like #4CAF50FF?
No -- this converter is scoped to the standard 3-digit and 6-digit RGB-only hex forms and does not accept the 4-digit (#RGBA) or 8-digit (#RRGGBBAA) forms that add an alpha/transparency channel. Those formats need an extra step to separate the alpha byte from the color bytes before the same base-16 decoding applies, which this tool doesn't perform.
How is this different from a hex-to-text or ASCII hex decoder?
They decode a completely different kind of hex string. A hex-to-text converter reads a run of hex byte pairs as UTF-8 text -- each byte pair becomes one character, like 48 65 6C 6C 6F decoding to "Hello". This converter instead reads exactly three (or six) hex digits as a CSS color, where each byte pair is a red, green or blue channel value, not a character code. The math (base-16 to decimal) is the same; what the resulting numbers mean is not.
What's the reverse of this conversion -- RGB back to hex?
Take each of the three RGB numbers (0-255), convert it to a two-digit hex pair, and concatenate the three pairs with a # in front -- the exact inverse of the steps here. RGB(76, 175, 80) becomes 4C, AF, 50 concatenated as #4CAF50. Because both directions are exact base conversions with no rounding, converting hex to RGB and back always returns the color you started with.