RGB to HEX Converter
To convert RGB to HEX, write each of the three values from 0 to 255 as a two-digit hexadecimal number and join them after a #. For example rgb(30, 144, 255) becomes #1E90FF. Type your numbers below to see the hex code, a preview and the HSL and CMYK values at once.
RGB to HEX converter
The live converter needs JavaScript. Example: #1E90FF = rgb(30, 144, 255) = hsl(210, 100%, 56%) = cmyk(88%, 44%, 0%, 0%).
- HEX
– - RGB
– - HSL
– - CMYK
–
CMYK is approximate. For print, use your printer’s color profile.
The formula
| Step | What to do | Example: dodger blue |
|---|---|---|
| 1 | Take each RGB value (0–255). | 30, 144, 255 |
| 2 | Write each as two hexadecimal digits (00–FF). | 30 → 1E, 144 → 90, 255 → FF |
| 3 | Join them after a #. | #1E90FF |
To convert one value by hand, divide it by 16. The whole number is the first digit and the remainder is the second, with 10 to 15 written as A to F. For 144: 144 ÷ 16 = 9 with remainder 0, so 90. For 30: 1 with remainder 14, so 1E.
Common RGB values in hex
| Color | RGB | HEX |
|---|---|---|
| Red | 255, 0, 0 | #FF0000 |
| Lime green | 0, 255, 0 | #00FF00 |
| Blue | 0, 0, 255 | #0000FF |
| White | 255, 255, 255 | #FFFFFF |
| Black | 0, 0, 0 | #000000 |
| Mid gray | 128, 128, 128 | #808080 |
| Dodger blue | 30, 144, 255 | #1E90FF |
| Tomato | 255, 99, 71 | #FF6347 |
| Gold | 255, 215, 0 | #FFD700 |
| Rebecca purple | 102, 51, 153 | #663399 |
| Teal | 0, 128, 128 | #008080 |
| Saddle brown | 139, 69, 19 | #8B4513 |
HSL rounded to whole numbers. CMYK from the simple formula below, without a color profile.
| Decimal | Hex | Decimal | Hex |
|---|---|---|---|
| 0 | 00 | 128 | 80 |
| 16 | 10 | 144 | 90 |
| 32 | 20 | 160 | A0 |
| 51 | 33 | 170 | AA |
| 64 | 40 | 192 | C0 |
| 85 | 55 | 204 | CC |
| 96 | 60 | 224 | E0 |
| 102 | 66 | 238 | EE |
| 112 | 70 | 240 | F0 |
| 119 | 77 | 255 | FF |
When you need which
Both codes describe exactly the same color. HEX is shorter and is what CSS, HTML and most design apps show by default. RGB numbers are what you see in Office programs, video tools, game engines and many programming libraries. Converting between them never changes the color.
Frequently asked questions
How do I convert RGB to HEX?
Convert each value from 0 to 255 into a two-digit hexadecimal number, then write them in the order red, green, blue after a #. For example 255, 99, 71 becomes FF, 63, 47, so the hex code is #FF6347.
What is 255, 255, 255 in hex?
255 in hexadecimal is FF, so rgb(255, 255, 255) is #FFFFFF, which is white. Likewise rgb(0, 0, 0) is #000000, black, and rgb(128, 128, 128) is #808080, a middle gray.
Can I convert RGBA to hex?
Yes. CSS accepts an eight-digit hex code where the last pair is the transparency: 255 is FF (opaque) and about 50% is 80. This converter handles the color part; add the alpha pair yourself if you need it.
Why does my RGB value give an error?
Each value must be a whole number from 0 to 255. Values above 255 or decimals are not valid in the standard 8-bit RGB used on the web. Percentages, as in rgb(50%, 0%, 0%), must first be multiplied by 2.55.
Is HEX more accurate than RGB?
No. A six-digit hex code and three numbers from 0 to 255 hold exactly the same information, so every RGB color has one hex code and back. Only the way of writing differs.
Last updated: October 15, 2026