Find your next tool

Browse tools or search by task

Explore JSONToonPro

Color Tools

RGB to HEX Converter – Convert RGB Color to Hex

Convert RGB color values to HEX codes online. Validate 0–255 channels, preview the color and copy CSS-ready hex output instantly.

Runs locally in your browser. Nothing you paste is uploaded.

RGB to HEX workspace

Enter 3, 4, 6 or 8 hex digits, optionally starting with #. Four and eight digits include alpha.

Alpha100%
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

Enter red, green and blue channels and copy the hexadecimal result. Each channel becomes a two-digit hexadecimal pair. Verify the preview so a mistyped value does not silently change the intended color.

RGB Channel Values From 0 to 255

Channels range from 0 to 255 and this interface clamps values to that range. Fractional values are rounded for byte output. Check incoming values rather than relying on clamping to diagnose an upstream error.

HEX Color Formatting

A full RGB HEX color has a hash followed by six digits. Zero-padding preserves two digits per channel. Letter case does not change the represented color; this tool displays uppercase HEX.

RGB to HEX Examples

RGB 37, 99, 235 becomes #2563EB. RGB 0, 0, 0 is #000000 and 255, 255, 255 is #FFFFFF. Optional alpha adds another pair and does not replace any channel.

Using HEX Colors in CSS

Use the copied code in CSS color properties and design tokens. When introducing alpha, test the composited result over the intended background. A numeric conversion alone does not establish accessible contrast.

More examples and technical details

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

How do I convert RGB to HEX?

Convert each 0–255 channel to two hexadecimal digits and join the three pairs, or use the tool.

What happens when an RGB value is outside 0–255?

The interface clamps it into range. Correct the source value if clamping was not intended.

Does the output use uppercase or lowercase hex?

The tool displays uppercase hexadecimal letters; lowercase represents the same color.

Can I convert alpha values too?

Yes. Adjust alpha to obtain a transparency-aware value.

Is conversion client-side?

Yes. No server conversion is needed.