Convert a hex color code to RGB instantly. Each pair of hex digits is one channel in base 16 — the tool shows that working for your exact input, gives both modern rgb(30 144 255) and legacy rgb(30, 144, 255) syntax, and previews the color as you type.
Generated locally in your browser — your colors, settings and code never leave this page.
Hexadecimal color codes, demystified
A hex color like #2e8b57 is three numbers wearing a disguise. The six digits after the # are three two-digit values in base 16 — red, green, blue in that order — using the digits 0–9 and then a–f for ten through fifteen. Two hex digits cover 0–255, exactly the range of an 8-bit RGB channel, which is why the notation exists: it is the shortest exact spelling of a 24-bit color.
The conversion is pure positional arithmetic. The first digit of each pair counts sixteens, the second counts ones. There is nothing approximate anywhere in the process — hex and RGB are two encodings of identical information.
Worked example: #2e8b57
Take seagreen, #2e8b57. Splitting into pairs gives 2e, 8b and 57:
2e = 2×16 + 14 = 46 (red) 8b = 8×16 + 11 = 139 (green) 57 = 5×16 + 7 = 87 (blue) #2e8b57 = rgb(46, 139, 87)
The letters trip people up at first: remember a=10 through f=15, so 8b is 8×16 + 11, not “8b”. The tool shows this working for whatever color you give it.
| Hex digit | 0 | 4 | 8 | a | c | f |
|---|---|---|---|---|---|---|
| Decimal value | 0 | 4 | 8 | 10 | 12 | 15 |
When you need RGB instead of hex
Any time channels are manipulated numerically: JavaScript canvas code, per-channel math, passing colors to APIs that want integers, or CSS work with alpha where rgb(46 139 87 / 60%) reads better than 8-digit hex. Hex remains the better interchange format — compact, universal, unambiguous — so real projects convert in both directions constantly.
The reverse direction lives at the RGB to HEX converter, and when your source value is HSL or a design-tool HSV reading, the dedicated converters for those formats skip the intermediate step.
Accuracy notes
This conversion is exact and lossless in both directions — verified in this site’s automated tests by round-tripping a grid across the whole RGB cube. The only judgment call is 3-digit shorthand (#2b5 expands to #22bb55 by digit doubling), which the parser applies per the CSS specification.
How to use the HEX to RGB Converter
- Pick the color with the native picker, or type its hex code into the twin field.
- The result updates live as you type – no convert button needed.
- Read the working under the preview: each hex pair converted from base 16 for your exact color.
- Copy the value with the copy button, or switch the output format dropdown for other export shapes.
Frequently asked questions
How do I convert HEX to RGB manually?
Split the six hex digits into three pairs and convert each pair from base 16: multiply the first digit by 16 and add the second. For #1e90ff: 1e = 1×16+14 = 30, 90 = 9×16+0 = 144, ff = 15×16+15 = 255 – so rgb(30, 144, 255). The tool prints this working for whatever color you enter.
What is the difference between rgb(30 144 255) and rgb(30, 144, 255)?
Nothing in the color – only the syntax generation. Space-separated is the modern CSS Color Level 4 syntax that also takes alpha after a slash; comma-separated is the legacy syntax every old browser understands. The tool outputs both so you can match your codebase.
Is HEX to RGB conversion ever lossy?
No. A six-digit hex code and an integer rgb() triplet encode exactly the same 24 bits of information, so the mapping is one-to-one in both directions. Loss only enters when a format uses fewer bits, like 3-digit shorthand hex.
Does this converter handle 3-digit shorthand hex like #fa0?
Yes. Shorthand expands each digit by doubling it – #fa0 means #ffaa00 – which is also why shorthand can only express a subset of colors: both digits of each channel must match.
Can I convert a HEX code with alpha, like #1e90ff80?
Use the dedicated HEX to RGBA converter for alpha work – it treats the fourth pair as opacity (80 hex = 128, about 50%) and emits rgba() syntax. This page focuses on the solid-color case.
Why do developers still use HEX at all?
Compactness and ubiquity: #1e90ff is shorter than any functional syntax, survives every design tool, email template and config file, and has no spaces to break parsers. RGB wins when you need to manipulate channels numerically.
Is the color I type here sent to a server?
No. The base-16 arithmetic runs in your browser; nothing you enter is uploaded, and analytics record only that the tool was used, never the color.