JSONToonPro
Color tool

RGB to HEX Converter

Convert RGB color values to a HEX code instantly. Enter red, green, and blue channels and copy the compact hex code, ready for CSS and design handoff. Everything runs 100% client-side in your browser, so your data never leaves your device.

100% client sideInstant resultNo data sent
Click to pick
HEX#2563EB
RGBrgb(37, 99, 235)
HSLhsl(221, 83%, 53%)

RGB channels

Red37
Green99
Blue235

HSL channels

Hue221deg
Saturation83%
Lightness53%

How to Convert RGB to HEX by Hand

Going from RGB to HEX is the reverse trip: you take three decimal channel values, each between 0 and 255, and rewrite each one as a two digit base 16 number. Stick the three results together, add a hash in front, and you have a HEX code.

The steps:

  1. Take the red value and divide by 16. The whole number is the first hex digit, the remainder is the second.
  2. Do the same for green, then blue. Values 10 through 15 are written as A through F.
  3. Concatenate the three two digit results in red, green, blue order.
  4. Add a leading hash to finish the code.

Worked example: rgb(255, 87, 51)

255 divided by 16 = 15 remainder 15, so 15 15 = FF
87 divided by 16 = 5 remainder 7, so 5 7 = 57
51 divided by 16 = 3 remainder 3, so 3 3 = 33
Result: #FF5733

Always Pad to Two Digits

The one thing people get wrong is dropping a leading zero. Every channel must become exactly two hex characters. A red value of 5 converts to 05, not 5, because a HEX code is read in fixed pairs. If you wrote #553 instead of #050503 the browser would read it as a completely different color, or as an invalid shorthand. When a channel converts to a single digit, pad it with a leading zero before joining the pairs.

rgb(5, 8, 200)
5 = 05, 8 = 08, 200 = C8
Result: #0508C8

Why Designers and CSS Prefer HEX

If RGB gives you the raw numbers, why convert back to HEX at all? Convenience. A HEX code is a single compact token, seven characters including the hash, that you can copy, paste, and share without commas, spaces, or a function wrapper. Design tools, style guides, and CSS variables almost all default to HEX because one string is easier to pass around than three separate numbers. It also reads cleanly in a diff and slots straight into a color swatch. RGB earns its keep when you are doing math on the channels, but for storing and communicating a fixed color, HEX is the tidier choice, which is why it remains the lingua franca of web color.

Named Color Reference

CSS ships with a set of keyword colors you can write by name instead of a code. They map to exact HEX and RGB values, so the table below is handy when you want to sanity check a conversion or reach for a familiar color without opening a picker.

NameHEXRGB
black#000000rgb(0, 0, 0)
white#FFFFFFrgb(255, 255, 255)
red#FF0000rgb(255, 0, 0)
green#008000rgb(0, 128, 0)
blue#0000FFrgb(0, 0, 255)
yellow#FFFF00rgb(255, 255, 0)
cyan#00FFFFrgb(0, 255, 255)
magenta#FF00FFrgb(255, 0, 255)
silver#C0C0C0rgb(192, 192, 192)
gray#808080rgb(128, 128, 128)
orange#FFA500rgb(255, 165, 0)
purple#800080rgb(128, 0, 128)
teal#008080rgb(0, 128, 128)
navy#000080rgb(0, 0, 128)

Need a different color task? Browse every free developer tool including color converters, encoders, and hashing utilities.

Frequently asked questions

4 answers
Take each channel value from 0 to 255 and rewrite it as a two digit base 16 number, then join the three results with a leading hash. For example rgb(255, 87, 51) becomes FF, 57, 33, which is #FF5733. Enter the channels above and the hex code appears instantly.

More JSON Tools