HEX to RGB
Turn any HEX code into its rgb() value instantly, ready to copy for CSS or code.
Steps to convert HEX to RGB
- Paste your hex code into the field, with or without the leading hash.
- Read the rgb() value that appears straight away.
- Click it to copy, ready for CSS, canvas or any RGB input.
- Need the alpha channel too? Carry on to RGBA.
How HEX to RGB conversion works
A hex code is just RGB written in base 16, so the conversion is a straight rewrite rather than a calculation that loses anything. Each of the three pairs becomes one channel from 0 to 255:
HEX and RGB compared
Why developers convert HEX to RGB
Designers hand over hex codes, but a lot of code cannot use them directly, and that gap is the whole reason this conversion is so common. The moment you need to animate a single channel, mix colors in JavaScript, or add transparency, separate 0 to 255 numbers are far easier to work with than a packed hex string. Keeping the hex for your stylesheet and the rgb() for your scripts is the practical habit.
What HEX to RGB is used for
- Feeding a color into canvas or WebGL, which expect numeric channels.
- Talking to an RGB-only API or hardware, like an LED strip.
- Building an rgba() value when you need to add opacity.
- Reading a color’s channels to tweak just one of them in code.
How to convert HEX to RGB in JavaScript
In code the conversion is three slices and a base-16 parse, which is why developers often inline it rather than reach for a library:
Yes, exactly. HEX is RGB written in base 16, so they are the same color.
A short code like #1AF expands by doubling each character to #11AAFF first, then converts as normal.
The first six digits give RGB as usual; the last pair is the alpha. Divide it by 255 for the 0 to 1 opacity, so #1E90FF80 is rgba(30, 144, 255, 0.5).
No. Both describe the same 0 to 255 channels, so the conversion is exact in both directions.
This tool handles one at a time; for many colors, convert each or use the full Color Converter.