Converter

Free RGB to HEX Converter

Convert any RGB colour value to HEX instantly. Also outputs HSL, HSV and CMYK — with live preview and batch conversion for multiple values at once.

Live conversion 100% offline Batch mode Live preview

RGB Input

rgb(37, 99, 235)
Channels
rgb
Invalid RGB. Use three numbers 0–255, e.g. rgb(37, 99, 235).
Recent conversions
No conversions yet — adjust the sliders above.

HEX Output

HEX colour
#2563EB
Red
37
0x25
Green
99
0x63
Blue
235
0xEB
Other formats
RGB rgb(37, 99, 235)
HSL hsl(221, 83%, 53%)
HSV hsv(221, 84%, 92%)
CMYK cmyk(84%, 58%, 0%, 8%)

About RGB to HEX Conversion

RGB and HEX are two ways of writing the same colour. An RGB value like rgb(37, 99, 235) gives the red, green and blue intensities as decimal numbers from 0 to 255. A HEX code like #2563EB gives those same three channels as pairs of hexadecimal digits. The colour is identical — only the notation differs.

Where HEX is compact and easy to paste, RGB is easier to manipulate in code — you can adjust individual channels, animate transitions, or compute new colours with arithmetic. Design tools usually give you HEX, but web APIs usually want RGB. This converter bridges the two instantly.

How RGB to HEX conversion works

Each RGB channel is a number from 0 to 255. Two hex digits can represent exactly 256 values (00 through FF), which is why each channel maps neatly to a pair. Convert each number to base 16, pad to two digits, and concatenate.

ChannelDecimalHex pairCalculation
Red37252×16 + 5 = 37
Green99636×16 + 3 = 99
Blue235EB14×16 + 11 = 235

So rgb(37, 99, 235) becomes #2563EB. The conversion is lossless — every RGB triplet maps to exactly one HEX code and vice versa.

Reference values

ColourRGBHEX
Blackrgb(0, 0, 0)#000000
Whitergb(255, 255, 255)#FFFFFF
Redrgb(255, 0, 0)#FF0000
Greenrgb(0, 255, 0)#00FF00
Bluergb(0, 0, 255)#0000FF
Mid greyrgb(128, 128, 128)#808080

Hex digit values

Each hex digit represents one of 16 values. Two digits give 16 × 16 = 256 combinations, matching the 0–255 range of an RGB channel.

DecimalHexDecimalHex
00012880
1610170AA
3220200C8
6440240F0
10064255FF

Alpha transparency (RGBA)

RGBA adds a fourth channel — alpha — controlling opacity from 0 (fully transparent) to 255 (fully opaque). Modern browsers support 8-digit HEX, where the last two digits are the alpha value:

This tool converts the three colour channels. To add alpha, append the two hex digits yourself using the pattern above.

Common use cases

CSS stylesheets

Convert design tool values into HTML-ready hex codes.

Canvas & WebGL

Convert runtime RGB into hex for style attributes.

Batch processing

Convert an entire palette at once.

Brand specs

Publish palettes in both RGB and HEX.

Accessibility

Convert computed RGB values for contrast tests.

Cross-format docs

Produce hex codes alongside CMYK for print.

Privacy and accuracy

This RGB to HEX converter runs entirely in your browser. All conversions happen locally in JavaScript with no server calls. The values you enter are never transmitted, stored or logged.

Frequently Asked Questions

How do I convert RGB to HEX?
Convert each RGB channel (0–255) to a two-digit hexadecimal number, then concatenate them. For example, rgb(37, 99, 235) becomes #2563EB: 37 in hex is 25, 99 is 63, and 235 is EB. Pad single-digit results with a leading zero.
Why do RGB values go from 0 to 255?
Because each channel is stored in one byte (8 bits), which can hold 256 distinct values: 0 through 255. 0 means no colour from that channel, 255 means full intensity. Three channels of 8 bits each give over 16 million possible colours (256 × 256 × 256).
What is the 2-digit hex for each channel?
Hex digits run 0–9 then A–F, giving 16 values per digit. Two hex digits give 16 × 16 = 256 possible values, which matches the 0–255 range of an RGB channel. So 0 becomes 00, 127 becomes 7F, 200 becomes C8 and 255 becomes FF.
Can I convert multiple RGB values at once?
Yes. Switch to Batch mode and paste as many RGB values as you like — one per line, in any of these forms: 37,99,235, rgb(37,99,235) or 37 99 235. The tool converts them all at once.
Is RGB to HEX lossless?
Yes. HEX and RGB describe the exact same three channel values, just in different number bases. HEX is base-16 and RGB is base-10, but no information is lost or rounded in either direction.
What about RGBA with alpha transparency?
RGBA adds a fourth channel for alpha (opacity). HEX supports this as 8-digit HEX where the last two digits are the alpha value, e.g. #2563EBCC is rgb(37, 99, 235) at 80% opacity. This tool converts the three colour channels; for alpha, append the 2-digit hex yourself.
Is this RGB to HEX converter free?
Yes, it is 100% free, requires no sign-up and runs entirely in your browser. No length limits, no watermarks, no premium tier.
Is my data sent to a server?
No. All conversions happen locally in JavaScript. The RGB values you enter are never transmitted, stored or logged.

Related Colour Tools

Done!