HEX to RGB Converter
Convert HEX color codes to RGB and RGB back to HEX, with the working shown step by step and a chart of common colors.
HEX ⇄ RGB
Result
Need HSV, CMYK or CSS color names? Try the color format converter.
Step by Step: #FF5733 → rgb(255, 87, 51)
Hex digits A–F stand for 10–15. Going the other way, divide each RGB value by 16: the quotient is the first digit and the remainder the second.
Lighter and Darker Versions
Related tools
How HEX Color Codes Work
A HEX color code is an RGB color written in base 16. The six digits after the # form three pairs, one each for red, green and blue, and each pair runs from 00 (none of that light) to FF (full intensity, 255). That gives 256 × 256 × 256 = 16,777,216 possible colors.
#RRGGBB → rgb(RR, GG, BB)
value = first digit × 16 + second digit (A=10 … F=15)
#FF5733 → FF = 255, 57 = 87, 33 = 51 → rgb(255, 87, 51)
Hex digits run 0–9 and then A–F:
Common Colors: HEX to RGB Chart
| Color | HEX | RGB |
|---|---|---|
| White | #FFFFFF | rgb(255, 255, 255) |
| Black | #000000 | rgb(0, 0, 0) |
| Red | #FF0000 | rgb(255, 0, 0) |
| Lime (pure green) | #00FF00 | rgb(0, 255, 0) |
| Blue | #0000FF | rgb(0, 0, 255) |
| Yellow | #FFFF00 | rgb(255, 255, 0) |
| Cyan / Aqua | #00FFFF | rgb(0, 255, 255) |
| Magenta / Fuchsia | #FF00FF | rgb(255, 0, 255) |
| Silver | #C0C0C0 | rgb(192, 192, 192) |
| Gray | #808080 | rgb(128, 128, 128) |
| Orange | #FFA500 | rgb(255, 165, 0) |
| Tomato | #FF6347 | rgb(255, 99, 71) |
| Navy | #000080 | rgb(0, 0, 128) |
| Teal | #008080 | rgb(0, 128, 128) |
| Rebecca Purple | #663399 | rgb(102, 51, 153) |
In CSS, “green” is #008000; the pure green channel #00FF00 is named “lime”.
Converting RGB Back to HEX
Divide each channel by 16: the whole-number part is the first hex digit and the remainder is the second. For rgb(52, 152, 219):
52 ÷ 16 = 3 remainder 4 → 34
152 ÷ 16 = 9 remainder 8 → 98
219 ÷ 16 = 13 remainder 11 → DB
→ #3498DB
Transparency is not part of RGB. To add it, use the HEX to RGBA converter; for HSV, CMYK or CSS color names, use the color format converter.
How to Use the HEX to RGB Converter
- 1Enter a HEX code: Type or paste a 3- or 6-digit HEX code, with or without #, or pick a color with the color picker.
- 2Or enter RGB: To go the other way, type three numbers from 0 to 255 such as 255, 87, 51 or rgb(255 87 51), or drag the red, green and blue sliders.
- 3Check the working: The step-by-step panel shows how each pair of hex digits becomes a number from 0 to 255.
- 4Copy the format you need: Copy HEX, CSS rgb(), the space-separated modern syntax, 0–1 values for Unity or SwiftUI, or HSL.
Frequently Asked Questions
How do I convert HEX to RGB?
Split the six digits into three pairs for red, green and blue, and convert each pair from base 16: first digit × 16 + second digit, where A–F mean 10–15. For #FF5733: FF = 15 × 16 + 15 = 255, 57 = 5 × 16 + 7 = 87 and 33 = 3 × 16 + 3 = 51, so rgb(255, 87, 51).
How do I convert RGB to HEX?
Divide each value by 16. The whole-number result is the first hex digit and the remainder the second. For 87: 87 ÷ 16 = 5 remainder 7, so 57. Put the three pairs after a #: rgb(255, 87, 51) is #FF5733.
What does a 3-digit HEX code like #F53 mean?
It is shorthand in which every digit is doubled, so #F53 is #FF5533 and #FFF is #FFFFFF (white). Only colors whose pairs repeat a digit can be written this way.
What about 8-digit HEX codes like #FF573380?
The last two digits are transparency (alpha), which plain RGB cannot store. This converter uses the first six digits; use the HEX to RGBA converter to keep the transparency as rgba().
How do I get RGB values between 0 and 1?
Divide each value by 255. rgb(255, 87, 51) becomes 1, 0.341, 0.2. Unity, SwiftUI, OpenGL, Blender and most shader code use this 0–1 form, and the converter shows it ready to copy.
Is HEX or RGB better for CSS?
They describe exactly the same colors, and browsers treat them identically. HEX is shorter and common in design handoffs; rgb() is easier to read and to adjust one channel at a time.
Related Tools
Hex-to-RGBA Converter
Add opacity to a HEX color: rgba(), 8-digit HEX and Android #AARRGGBB.
Color Format Converter
Convert HEX, RGB, HSL, HSV and CMYK, including alpha and CSS color names.
HSL Color Slider
Adjust hue, saturation, and lightness with live preview.
Random Hex Color Generator
Spacebar to refresh color inspiration.
Duotone Image Filter
Apply a two-colour gradient map to images for modern artistic effects.
Color Palette Extractor
Upload image to get 5 dominant colors.
Color Palette Generator
Generate harmony-based palettes with export and contrast checks.
CSS Gradient Generator
Create linear and radial gradients with copy-ready CSS.
CSS Box Shadow Generator
Build layered shadows with live preview and copy-ready CSS.
CSS Glassmorphism Generator
Create frosted glass effects with live preview and copy-ready code.
SVG Path Visualizer
Draw SVG path data on a grid with every command explained.
Contrast Checker
Test WCAG AA and AAA color contrast accessibility.