Color Conversion Tools
RGB to HEX
Write red, green and blue channel values as a HEX color code. Enter three numbers from 0 to 255, see the swatch, and copy a lowercase #rrggbb token ready for CSS, design tokens or a brand guide.
Edit a channel and see the color result immediately.
Enter RGB
RGB channels are whole numbers from 0 to 255.
HEX result
The conversion runs in your browser.
All formats
- HEX
#336699- RGB
rgb(51, 102, 153)- HSL
hsl(210, 50%, 40%)- HSV
hsv(210°, 66.7%, 60%)- CMYK
cmyk(66.7%, 33.3%, 0%, 40%)- OKLCH
oklch(49.9% 0.099 250.4)- CSS
≈ steelblue
Tints and shades
Text contrast (WCAG)
Normal text needs 4.5:1 for AA and 7:1 for AAA; large text needs 3:1.
How it was calculated
R: 51 = 3 × 16 + 3 → 33G: 102 = 6 × 16 + 6 → 66B: 153 = 9 × 16 + 9 → 99HEX = #336699
Common colors in RGB and HEX
Choose a color to load it into the converter.
| Color | RGB | HEX |
|---|---|---|
rgb(0, 0, 0) | #000000 | |
rgb(255, 255, 255) | #ffffff | |
rgb(255, 0, 0) | #ff0000 | |
rgb(0, 255, 0) | #00ff00 | |
rgb(0, 0, 255) | #0000ff | |
rgb(255, 255, 0) | #ffff00 | |
rgb(0, 255, 255) | #00ffff | |
rgb(255, 0, 255) | #ff00ff | |
rgb(128, 128, 128) | #808080 | |
rgb(128, 0, 0) | #800000 | |
rgb(0, 128, 0) | #008000 | |
rgb(0, 0, 128) | #000080 | |
rgb(255, 165, 0) | #ffa500 | |
rgb(70, 130, 180) | #4682b4 | |
rgb(102, 51, 153) | #663399 | |
rgb(255, 99, 71) | #ff6347 |
How to use
- Enter the red, green and blue channels as whole numbers from 0 to 255.
- Check the preview and the #rrggbb result; the calculation panel shows each channel split into two hex digits.
- Copy the HEX code, or pick a nearby tint or shade from the strip below the converter and copy that instead.
Examples
Pure orange
255 is ff, 165 is 10 × 16 + 5 = a5, and 0 is written with a leading zero as 00.
rgb(255, 165, 0)
#ffa500
A deliberately sequential code
18 = 1 × 16 + 2, 52 = 3 × 16 + 4 and 86 = 5 × 16 + 6, which is why this dark blue spells 123456.
rgb(18, 52, 86)
#123456
When you need RGB as HEX
RGB numbers are what measuring tools give you; HEX is what most people paste. Common situations:
- You sampled a pixel. An eyedropper in an image editor or the browser reports
rgb(255, 165, 0). A design token or a Tailwind config wants#ffa500. - You generated a color in code. Interpolating between two colors, or reading a chart palette, produces channel numbers that need a stable string for storage.
- You are filling in a brand guide. Brand sheets traditionally list HEX next to RGB and CMYK, so having both forms avoids transcription mistakes.
How the conversion works
Each channel is written in base 16 with exactly two digits. Divide by 16: the whole part is the first digit and the remainder is the second, with 10–15 written as a–f.
For rgb(255, 165, 0):
- 255 = 15 × 16 + 15 →
ff - 165 = 10 × 16 + 5 →
a5 - 0 = 0 × 16 + 0 →
00
Join them after a hash and the result is #ffa500. The calculation panel shows this division for the value you type, which makes it easy to check a code someone wrote by hand.
Details that trip people up
- Channel order. HEX is always red, green, blue. Some graphics APIs and file formats store BGR, so
rgb(0, 165, 255)from such a source is actually orange written backwards. The live preview makes this obvious. - Out-of-range values. 256 or -1 are not valid channels; the converter marks the field instead of wrapping the number.
- Transparency. An alpha channel is not part of this pair. If you need
#ffa50080, use the general Color Converter.
To go the other way, open HEX to RGB. For a print estimate, continue with RGB to CMYK.
Frequently asked questions
Where do RGB values usually come from?
From a screenshot or eyedropper tool, a canvas getImageData call, a chart library, or a spreadsheet. Converting them to HEX gives one compact token you can paste into CSS or share with a designer.
Why does each channel need two digits?
A channel holds 256 levels, and two hexadecimal digits cover exactly 16 × 16 = 256 values. Small numbers keep a leading zero, so 9 becomes 09 and the code stays six digits long.
Can I enter decimals or percentages?
Not on this page. RGB channels here are whole numbers from 0 to 255, which is what a HEX code can represent. Round a value such as 127.5 to 128 first.
Should the HEX code be upper or lower case?
Either works in CSS and design tools. The converter outputs lowercase, which is the most common style in stylesheets and linters.
Is the result exact?
Yes. Every RGB triple has exactly one six-digit HEX code, so converting back with HEX to RGB returns the same numbers.