RGB to HEX Converter
Got a colour as three numbers and need the code your stylesheet wants? This rgb to hex converter takes red, green and blue values such as 37, 99 and 235 and rewrites them as the single code #2563EB. Fill in the three channels — or paste a whole rgb() string in one go — check the preview, and take the hex away with you. The conversion runs in your browser, so the colour values never leave your device.
#2563EB
rgb(37, 99, 235) becomes the single hex code #2563EB.
Convert RGB to HEX
Enter the three channel values and read off the hex code.
HEX result — shown with a preview of your colour
Each channel becomes exactly two hex digits, so a small value keeps its leading zero — 12 becomes 0C, not C.
Why colours travel better as hex
Three numbers on the way in, one portable code on the way out.
Ready for your stylesheet
CSS has accepted hex since the beginning, and so have SVG files, email HTML and design-tool colour fields. Converting an rgb to hex color gives you the spelling all of them share.
Paste it whole, or type it whole
Use whichever you have — three separate values from a picker, or a finished rgb() string copied from browser developer tools. The paste field saves re-typing channels one by one.
The same colour, guaranteed
Because 256 is exactly 16 × 16, every channel value has one precise two-digit hex spelling. Nothing is rounded or approximated, so #2563EB displays exactly as rgb(37, 99, 235) did.
About this converter
RGB describes a colour the way a screen builds it: three channels of light, each an ordinary number from 0 (off) to 255 (fully on). Hex describes the very same colour the way the web prefers to file it — those numbers rewritten in base 16 and packed behind a #. Turning an rgb color to hex is therefore a translation, not a transformation: 37, 99 and 235 go in, and #2563EB comes out, pixel for pixel identical.
Doing that translation by hand means dividing each channel by 16 three times and remembering that remainders from 10 to 15 are written A to F — and that a result under 16 still needs its leading zero. It is a small job that is remarkably easy to get wrong in a hurry. This rgb to hex converter takes the rgb values to hex in one step, whether you type the channels separately or paste the whole rgb() string, and shows the preview so you can confirm the shade before it goes into production.
Frequently asked questions
The divide-by-16 method, leading zeros, and what hex can and cannot carry.
How do I convert RGB to HEX on this page?
Enter a whole number from 0 to 255 in each of the Red, Green and Blue fields — or paste a complete value such as rgb(37, 99, 235) into the paste field. The tool rewrites each channel as two hex digits, joins them in order, and shows you the code — #2563EB in this example — next to a preview of the colour.
What does a hex code actually stand for?
It is the same RGB colour written in hexadecimal (base 16) instead of decimal. After the #, the six characters form three pairs — #RRGGBB — for red, green and blue in that order. Each pair runs from 00 to FF, which is simply 0 to 255 counted in base 16, using the letters A to F for the values 10 to 15.
What is the difference between RGB and HEX?
Only the notation. RGB lists the channels as three decimal numbers, which suits sliders, pickers and code that adjusts channels one at a time. HEX compresses the identical channels into one short string, which suits stylesheets, tokens and sharing. Neither holds more colour information than the other, and any colour written one way can be written the other way.
How do I convert RGB to hex manually?
Take each channel on its own and divide it by 16: the whole-number result is the first hex digit and the remainder is the second, with 10–15 written as A–F. So 37 ÷ 16 is 2 remainder 5, giving 25; 99 gives 63; and 235 gives EB. Join the pairs in red-green-blue order and add the #: #2563EB. The trap to avoid is a one-digit result — 12 is 0C, never just C, because every pair must be two digits.
Can I use the result in CSS, and is the conversion exact?
Yes to both. A code such as #2563EB can be pasted directly as a CSS colour value — for text, backgrounds, borders and anywhere else a colour is accepted — and it works in every browser. The conversion is also exact rather than approximate: each of the 256 possible channel values maps to one unique two-digit hex pair, so converting to hex and back returns the original colour unchanged.
Does this tool handle transparency or shorthand hex?
The page is built for solid colours: it takes the three opaque channels and returns the full six-digit code. If your colour needs transparency, that belongs in an rgba() value in your CSS, where you add the alpha separately — this tool does not take an alpha input. Likewise, the output stays in the full #RRGGBB form rather than the 3-digit shorthand (#25E-style codes only exist when every pair repeats a digit); the long form is accepted everywhere, so it is the safer thing to hand over.