RGB to HEX Converter
Convert between RGB and HEX color values in both directions, with a live preview. Out-of-range values are clamped rather than silently producing a broken color.
RGB → HEX
Three numbers from 0 to 255, separated by commas or spaces.
HEX → RGB
3 or 6 digits, with or without the leading #.
How RGB to HEX conversion works
HEX is simply base-16 notation for the same three channels. Each channel (0–255) becomes a two-digit hexadecimal pair:
#RRGGBB where each pair = value.toString(16).padStart(2, '0')
Worked example. Convert rgb(11, 107, 203):
- Red 11 →
11 ÷ 16 = 0remainder11→0B - Green 107 →
107 ÷ 16 = 6remainder11→6B - Blue 203 →
203 ÷ 16 = 12remainder11→CB
Result: #0B6BCB
Common colors
| Name | HEX | R | G | B |
|---|---|---|---|---|
| Black | #000000 | 0 | 0 | 0 |
| White | #FFFFFF | 255 | 255 | 255 |
| Red | #FF0000 | 255 | 0 | 0 |
| Lime | #00FF00 | 0 | 255 | 0 |
| Blue | #0000FF | 0 | 0 | 255 |
| Cyan | #00FFFF | 0 | 255 | 255 |
| Magenta | #FF00FF | 255 | 0 | 255 |
| Yellow | #FFFF00 | 255 | 255 | 0 |
| Gray | #808080 | 128 | 128 | 128 |
| Crimson | #DC143C | 220 | 20 | 60 |
| Teal | #008080 | 0 | 128 | 128 |
| Navy | #000080 | 0 | 0 | 128 |
Frequently asked questions
- How do I convert RGB to HEX by hand?
- Convert each of the red, green and blue values (0–255) to a two digit base-16 number, then join them with a leading hash. For example rgb(11, 107, 203) becomes #0B6BCB.
- What happens if I enter a value above 255?
- Values are clamped to the valid 0–255 range, so 300 is treated as 255. The converter shows a note whenever clamping occurs so you always know the real output.
- Does this tool support 3-digit HEX codes?
- Yes. Shorthand codes such as #0af are expanded to #00AAFF, and you can enter them with or without the leading hash.
- Is my data uploaded anywhere?
- No. The conversion runs entirely in your browser; no color value is ever sent to a server.
Related tools
RGBA → HEX
Convert colors that include an alpha channel.
Text ↔ Binary
Convert text to binary using real UTF-8.
JSON ↔ XML
Two-way developer format conversion.
Decimal → Octal
Base-10 to base-8 number conversion.
Epoch → Date
Turn a Unix timestamp into a readable date.
BPM → Milliseconds
Note lengths in ms for delay timing.
Last updated: August 31, 2026