RGB to HEX Converter
HEX code
#3B82F6
rgb(59, 130, 246)
Enter red, green, and blue values from 0 to 255 and get the HEX code instantly. Free RGB to HEX converter with sliders, live preview, and copy button.
What is RGB to HEX conversion?
RGB to HEX conversion turns three numbers from 0 to 255 into one six-digit HEX code. Red, green, and blue are the three channels of light a screen mixes, and HEX is the short way web code writes those same three numbers. The converter takes your three RGB numbers and gives you the HEX code to paste into CSS, Figma, or Canva.
The two notations describe the exact same color, so nothing is lost in the change. RGB says the color in three decimal numbers, HEX says it in three two-digit hex pairs, and the converter translates between them instantly. If you know the RGB values from a design file, this tool gives you the code the web needs.
Three sliders, one live HEX code
Red255 · FF
Green87 · 57
Blue51 · 33
#FF5733
Worked example: rgb(255, 87, 51) = #FF5733
The RGB color rgb(255, 87, 51) converts to the HEX code #FF5733. Red 255 becomes FF, green 87 becomes 57, and blue 51 becomes 33, and the three pairs join after the hash to make #FF5733. It is a bright coral-orange, the kind of color used for buttons and highlights.
Each pair comes from the same divide-by-16 step. Red 255 divided by 16 is 15 with a remainder of 15, and 15 in hex is F, so the pair is FF. Green 87 divided by 16 is 5 with a remainder of 7, giving 57. Blue 51 divided by 16 is 3 with a remainder of 3, giving 33.
255 ÷ 16
15 rem 15 → FF
87 ÷ 16
5 rem 7 → 57
51 ÷ 16
3 rem 3 → 33
Joined code: #FF5733
Worked example: rgb(59, 130, 246) = #3B82F6
The RGB color rgb(59, 130, 246) converts to the HEX code #3B82F6. Red 59 becomes 3B, green 130 becomes 82, and blue 246 becomes F6, joining to #3B82F6. It is a clear medium blue, widely used for links and buttons, and it appears as a worked example across several ranking pages.
Check the red channel by hand: 59 divided by 16 is 3 with a remainder of 11, and 11 in hex is B, so the pair is 3B. Green 130 divided by 16 is 8 with a remainder of 2, giving 82. Blue 246 divided by 16 is 15 with a remainder of 6, giving F6. The same step works for every channel.
59 ÷ 16
3 rem 11 → 3B
130 ÷ 16
8 rem 2 → 82
246 ÷ 16
15 rem 6 → F6
Joined code: #3B82F6
Worked example: rgb(52, 152, 219) = #3498DB
The RGB color rgb(52, 152, 219) converts to the HEX code #3498DB. Red 52 becomes 34, green 152 becomes 98, and blue 219 becomes DB, joining to #3498DB. It is a bright sky blue, and it is a good third example because its red channel is small while its green and blue channels are large.
The hand check again: 52 divided by 16 is 3 with a remainder of 4, giving 34. Green 152 divided by 16 is 9 with a remainder of 8, giving 98. Blue 219 divided by 16 is 13 with a remainder of 11, and 13 in hex is D and 11 is B, giving DB. Three examples are enough to see the method never changes.
52 ÷ 16
3 rem 4 → 34
152 ÷ 16
9 rem 8 → 98
219 ÷ 16
13 rem 11 → DB
Joined code: #3498DB
How to convert RGB to HEX by hand
To convert RGB to HEX by hand, divide each channel by 16, then write the quotient and the remainder as hex digits. The quotient is the first digit and the remainder is the second digit, and remainders from 10 to 15 become the letters A to F: 10 is A, 11 is B, 12 is C, 13 is D, 14 is E, and 15 is F. Do that for red, green, and blue, then join the three pairs after a hash.
Take green 87 as the example to remember. Divide 87 by 16 to get 5 with a remainder of 7, so the pair is 57 — the 5 is the quotient and the 7 is the remainder. If the remainder had been 11 instead, the pair would end in B, as in 59 giving 3B. Two digits per channel, three channels, six digits total.
Hand method for green 87
87 ÷ 16
quotient 5
remainder 7
second digit 7
pair 57
5 then 7
Remainders 10 to 15 become letters: 10 = A, 11 = B, 12 = C, 13 = D, 14 = E, 15 = F.
Why HEX is the code the web uses
HEX is the code the web uses because it is short, exact, and pasteable in one piece. CSS takes a HEX code as a single value, for example color: #FF5733;, while RGB needs a function with three numbers and commas. HEX is also how Figma, Canva, and most design tools show a color, so converting to HEX is the step that makes an RGB value usable.
There are 16,777,216 possible HEX colors — 256 values per channel, three channels, 256 × 256 × 256 — which is every color a standard screen can show. The converter covers all of them, from #000000 (black, all channels 0) to #FFFFFF (white, all channels 255), and every shade in between.
#FF5733
CSS rule
color: #FF5733;Figma color field
#FF5733
Canva color field
#FF5733
From #000000 (black) to #FFFFFF (white): 16,777,216 colors in all.
Common mistakes when entering RGB values
The most common mistake is entering a value above 255, usually 256 or 300, which no channel can hold. Each channel is one byte, so its range is 0 to 255 and nothing higher. A second mistake is entering a percentage — 100% red is 255, not 100 — and a third is typing a decimal like 130.5, which has no meaning for a channel. The tool rejects all three and says which channel is wrong.
A quieter mistake is swapping the channels, especially red and green, which turns an orange into a green. The labelled sliders and fields prevent that: red is always first, green second, blue third, and the swatch updates live, so a swapped value shows the wrong color immediately and you can fix it before copying.
300 → Enter a number from 0 to 255
Corrected: 255 (the highest a channel can hold).
100 typed for 100% → accepted, but 100% red is not 100
Corrected: 255 — a percentage is a different scale.
130.5 → Use a whole number from 0 to 255.
Corrected: 130 (a channel takes whole numbers only).
Red is always first, green second, blue third — a swapped value shows the wrong color at once.
All color tools
21 tools, one topic — see About Hex Color Code Picker for who built this site.
- Color Picker from ImageUpload an image, click a pixel, and read its HEX code.
- Screen EyedropperSample any pixel on your screen.
- RGB to HEX ConverterTurn three RGB numbers into one HEX code.
- HEX to RGB ConverterTurn a HEX code into three RGB numbers.
- HEX to HSL ConverterTurn a HEX code into hue, saturation, and lightness.
- HSL to HEX ConverterTurn HSL values back into a HEX code.
- HEX to HSV ConverterTurn a HEX code into hue, saturation, and value.
- HEX to CMYK ConverterTurn a HEX code into approximate print values.
- RGB to HSL ConverterTurn RGB numbers into hue, saturation, and lightness.
- HEX to OKLCH ConverterTurn a HEX code into the modern OKLCH format.
- Color ConverterSee one color in every format at once.
- HEX to RGBA ConverterTurn a HEX code into RGB with transparency.
- Color Name to HEXLook up any of the 148 CSS named colors.
- Color Palette GeneratorBuild a five-color palette from one color.
- Shades GeneratorBuild 10 tints and 10 shades from one color.
- Gradient GeneratorBuild a linear or radial gradient and copy the CSS.
- Contrast CheckerCheck any text and background pair for AA and AAA.
- Color MixerMix two colors and see the result.
- Random Color GeneratorPick a random color from all 16,777,216 HEX colors.
- Color Blindness SimulatorSee your colors as color-blind users see them.
- Color ChartThe 148 named colors with HEX, RGB, and HSL.
No tool matches your search.
Frequently asked questions
Enter the red, green, and blue values from 0 to 255 and copy the HEX code. Type the numbers or drag the sliders, and the HEX code updates live. Click Copy to paste it into CSS, Figma, or Canva.
#FF5733. Red 255 is FF, green 87 is 57, and blue 51 is 33. It is a bright coral-orange used for buttons and highlights.
#3B82F6. Red 59 is 3B, green 130 is 82, and blue 246 is F6. It is a clear medium blue used for links and buttons.
Divide each channel by 16; the quotient is the first hex digit and the remainder is the second. Remainders 10 to 15 become A to F. For example, 87 divided by 16 is 5 remainder 7, giving 57, and 59 divided by 16 is 3 remainder 11, giving 3B.
Because each RGB channel holds one byte, so its range is 0 to 255. A value of 256 or higher cannot exist in a channel. Enter a whole number from 0 to 255 for each of red, green, and blue.
Not in this tool — enter the 0 to 255 value. A percentage is a different scale: 100% is 255, 50% is about 128, and 0% is 0. If your source gives percentages, multiply the percentage by 255 and divide by 100 to get the channel value.