Color Converter HEX to RGB: Formula, Examples and Free Tool
Designers hand over colours as HEX codes, but CSS effects, apps and design tools often want RGB values instead. A color converter HEX to RGB does the switch instantly, and once you see how it works, you can even do it in
Designers hand over colours as HEX codes, but CSS effects, apps and design tools often want RGB values instead. A color converter HEX to RGB does the switch instantly, and once you see how it works, you can even do it in your head.
This guide shows how a color converter HEX to RGB works, walks through the maths with real examples and covers HSL and CMYK too.
Quick answer: A HEX code is three pairs of hexadecimal digits for red, green and blue. Convert each pair to a number from 0 to 255 and you have the RGB value: #FF5A1F becomes rgb(255, 90, 31). Paste any HEX code into a free colour converter to get RGB, HSL and CMYK at once.
How to use a color converter HEX to RGB
- Open the tool. Go to the free Color Converter.
- Enter your HEX code. Type or paste it, for example #ff5a1f.
- Read the RGB value. Youβll see rgb(255, 90, 31).
- Grab other formats. HSL is shown too, plus CMYK as a print reference.
- Go the other way. Type RGB or HSL values to get the HEX code.
How HEX to RGB conversion works
HEX uses base 16, with the digits 0 to 9 and the letters A to F (A = 10, B = 11 and so on up to F = 15). Each pair equals first digit Γ 16 + second digit. For #FF5A1F:
- FF = 15 Γ 16 + 15 = 255 (red)
- 5A = 5 Γ 16 + 10 = 90 (green)
- 1F = 1 Γ 16 + 15 = 31 (blue)
So #FF5A1F = rgb(255, 90, 31). To go back, divide each RGB number by 16: 90 Γ· 16 = 5 remainder 10, which gives 5A.
Common colours in HEX and RGB
| Colour | HEX | RGB |
|---|---|---|
| White | #FFFFFF | rgb(255, 255, 255) |
| Black | #000000 | rgb(0, 0, 0) |
| Red | #FF0000 | rgb(255, 0, 0) |
| Green | #00FF00 | rgb(0, 255, 0) |
| Blue | #0000FF | rgb(0, 0, 255) |
| Bright orange | #FF5A1F | rgb(255, 90, 31) |
| Charcoal | #15171C | rgb(21, 23, 28) |
| Off-white | #FAF9F6 | rgb(250, 249, 246) |
HEX vs RGB vs HSL vs CMYK
| Format | Looks like | Best for |
|---|---|---|
| HEX | #FF5A1F | CSS, design handoff and brand guides |
| RGB | rgb(255, 90, 31) | Code, apps and transparency with rgba() |
| HSL | hsl(16, 100%, 56%) | Making lighter or darker shades by changing lightness |
| CMYK | Percentages of cyan, magenta, yellow and black | Print reference |
In the tool, CMYK is display-only, because converting CMYK back to RGB depends on the printer and ink profile.
Why convert HEX to RGB?
- Transparency: rgba(255, 90, 31, 0.5) gives a see-through overlay. Modern CSS also accepts 8-digit HEX such as #FF5A1F80.
- Apps and code: many mobile, game and Python libraries take RGB values, sometimes as 0 to 1 decimals (90 Γ· 255 β 0.353).
- Design tools: some colour pickers only accept RGB numbers.
- Charts: data visualisation libraries often use RGB arrays.
Shorthand HEX codes
Three-digit codes are shorthand, with each digit doubled: #FFF is #FFFFFF (white), and #0A3 is #00AA33, which is rgb(0, 170, 51). Need a full set of matching colours? Build one with the Color Palette Generator.
Tips for working with colour codes
- Keep one source of truth. Store brand colours as CSS variables or in a style guide, not scattered across files.
- Check contrast. Text and background need enough contrast to stay readable: WCAG recommends at least 4.5:1 for normal text.
- Remember screens and print differ. A bright RGB orange can print duller in CMYK, so ask your printer for a proof.
- Copy, donβt retype. One wrong character in a HEX code gives you a different colour.
Example: a semi-transparent overlay
Say your brand orange is #FF5A1F and you want it at 60% opacity over a hero image. Convert it to get rgb(255, 90, 31), then write rgba(255, 90, 31, 0.6) in your CSS. The text on top stays readable, and the colour still matches your brand. A color converter HEX to RGB turns that into a ten-second job.
Frequently asked questions
Which formats can I type in?
HEX (such as #ff5a1f), RGB (such as rgb(255, 90, 31)) and HSL.
Why is CMYK read-only?
CMYK is mainly for print, and converting it back to RGB is lossy and depends on the printer and ink profile, so itβs shown as a reference value.
Is a HEX code case-sensitive?
No. #ff5a1f and #FF5A1F are the same colour.
Whatβs the range of RGB values?
Each channel goes from 0 to 255, giving more than 16 million possible colours.
Is this color converter HEX to RGB free?
Yes. Itβs free, works in your browser and needs no signup.
Convert any colour code in seconds. Open the free Color Converter and paste your HEX code.
This guide was first published on ToolKitFree, where you can use the free tool online.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.