Converters

RGB to HEX converter

Convert RGB to HEX in one step

Enter red, green and blue values from 0 to 255 and this RGB to HEX converter returns a CSS-ready hex code the moment you type. Compare the same colour as CMYK ink percentages, HSL and a live swatch, or edit the HEX field when you need the reverse direction.

  • No submit button — converts as you type
  • 100% client-side — nothing is uploaded
  • No account

Converter

RGB to HEX conversion, both ways

Start from the channel values, or flip over and type a hex code. Everything stays in sync.

3 or 6 digits

Enter a 3 or 6 digit hexadecimal colour, with or without the leading hash.

RGB channels — 0 to 255

Dial in a channel directly, or let it follow the HEX.

CMYK inks — edit any value

Every field is live. Change an ink and the HEX updates instantly.

0%
0%
0%
0%
Recent
Nothing yet.
Colour wheel

Hue and saturation — drag the marker, or use the arrow keys (hold Shift for larger steps).

100%
#7C3AED
HEX
#7C3AED
CMYK
cmyk(48%, 76%, 0%, 7%)
RGB
rgb(124, 58, 237)
HSL
hsl(262, 83%, 58%)

Total ink coverage

131%

Within the ~300% most commercial presses accept.

CMYK here is the standard sRGB approximation — a faithful preview, not a press-calibrated match.

RGB to HEX guide

RGB to HEX converter: turn red, green and blue values into a hex color code

Channel numbers are precise but awkward to paste into a stylesheet. This guide shows how an RGB to HEX converter works, how to convert RGB to HEX by hand, the exact formula behind it, and where a six-digit RGB hex value is the more useful notation.

What an RGB to HEX converter does

An RGB to HEX converter turns three channel values — red, green and blue — into the six-character notation that CSS, design tools and brand guidelines expect. RGB is how screens describe colour: each channel runs from 0 to 255, so a value such as rgb(37, 99, 235) tells a display exactly how much red, green and blue light to emit. HEX carries the same information in base 16, written as three pairs of digits after a hash, such as #2563EB. Neither format is more accurate than the other; they are two spellings of one colour. The converter earns its place when a colour arrives as channel numbers — from a design handoff, a charting library, a canvas API or a brand document — and has to become an RGB to HEX code that can be pasted straight into a stylesheet. It removes the repetitive arithmetic and shows the result beside CMYK and HSL so the colour can be checked from several angles at once.

How to convert RGB to HEX, step by step

To convert RGB to HEX by hand, treat each channel as a number between 0 and 255 and translate it into exactly two hexadecimal digits. Start with red: divide the value by 16, round the quotient down to a whole number, and write that down. Take the remainder and write it as the second digit. Values 10 to 15 become A to F, so a remainder of 11 is B and a remainder of 14 is E. Repeat the same two steps for green, then blue, always in that order. Join the three pairs and put a hash in front. For rgb(37, 99, 235), the red channel 37 gives 2 remainder 5, or 25; green 99 gives 6 remainder 3, or 63; blue 235 gives 14 remainder 11, or EB. The RGB to HEX conversion is therefore #2563EB. Every channel is a whole number from 0 to 255, so every pair is valid and the result can always be converted back without loss.

The RGB to HEX formula in plain terms

As a formula, the RGB to HEX calculation for a channel value V has two parts: the first digit is floor(V ÷ 16) and the second is V mod 16, with both digits mapped through 0–9 and A–F. A full colour is the three pairs joined in red, green, blue order, written as #RRGGBB. The same RGB to HEX formula works in reverse. Multiply the first digit of a pair by 16, add the second digit, and the original channel returns: the pair EB is 14 × 16 + 11 = 235. That symmetry is why the conversion never drifts. One number has exactly one two-digit hexadecimal representation, and one pair has exactly one decimal value, so no rounding or colour profile is involved. The only choices left are presentation details: upper or lower case, and whether the leading hash is shown.

A worked example: convert a blue RGB value to HEX

Take a strong blue, rgb(37, 99, 235). Red 37 becomes 2 × 16 = 32 with a remainder of 5, so the red pair is 25. Green 99 becomes 6 × 16 = 96 with a remainder of 3, so the green pair is 63. Blue 235 becomes 14 × 16 = 224 with a remainder of 11, so the blue pair is EB. Joined together, the RGB to HEX color is #2563EB, and CSS accepts either spelling: color: rgb(37, 99, 235) or color: #2563EB. Try a near-black next, rgb(17, 24, 39). The pairs are 11, 18 and 27, giving #111827. Low values often produce small digits, which is why some hex codes look shorter than expected. The hash is not part of the six digits; it is a marker that tells CSS the characters that follow are hexadecimal.

Where RGB and RGB hex values are used

RGB values are the native input for anything that draws pixels, so RGB to HEX codes travel between several kinds of tools. In CSS, the hex form is compact and appears in most design tokens and style guides, while rgb() and rgba() stay useful when a single channel has to be adjusted or transparency added. In JavaScript, canvas drawing, WebGL and charting libraries usually want three separate numbers, so you convert RGB to HEX only when the value must become a string in a configuration file or stylesheet. Design tools show both views: a picker may display a hex field while the eyedropper samples channel values. Accessibility work also begins with RGB, because relative luminance and contrast ratios are derived from linearised red, green and blue. Marketing teams paste an RGB hex value into email templates and page builders that reject rgb() syntax. Hardware and image pipelines describe colour as three channels too. Converting to hex is often the final step — the point where numeric colour becomes a portable RGB to HEX code.

Three-digit shorthand and common mistakes

Some RGB to HEX code values can be shortened. When both digits in every pair are identical, the six-digit form reduces to three: #FF6633 becomes #F63, and #FFFFFF becomes #FFF. Browsers expand the shorthand by doubling each digit, so #F63 means #FF6633. If the pairs are not identical — #2563EB, for example — shorthand is invalid and should not be used. Two mistakes are common when converting by hand. The first is writing the channels in the wrong order; RGB to HEX always reads red, then green, then blue. The second is treating A to F as decimal digits. In base 16, A is 10 and F is 15, so the pair FF is 255, not 151. A quick sanity check helps: if the colour is mostly blue, the last pair should be the largest; if it is mostly red, the first pair should be.

RGB to HEX vs HEX to RGB: the same colour both ways

An RGB to HEX conversion is one direction of a two-way relationship. Converting a hex value back to RGB reverses the arithmetic: read each pair, multiply the first digit by 16, add the second, and the channel returns. Because both notations describe the same sRGB value, a round trip changes nothing. A colour that starts as rgb(37, 99, 235), becomes #2563EB, and returns to rgb(37, 99, 235) is identical on screen, and every color RGB to HEX conversion gives the same six-digit result on every device. The confusion usually comes from mixing colour spaces rather than notations. Hex and RGB are both screen formats; CMYK describes ink on paper and is only an approximation. A project may need the hex code for a website and ink percentages for a printer, and those readings will not match perfectly because they describe different media. Keep the hex value as the source of truth for the screen and treat CMYK as a starting point for print.

Why use this RGB to HEX converter

This RGB to HEX converter is built for fast, repeated work. Conversion happens as you type — there is no submit button — so a palette of channel values can be tested in seconds. The red, green and blue fields accept numbers from 0 to 255, and the hex output updates immediately. If you would rather work the other way, the HEX field is editable and the channels follow. The colour wheel, native picker and screen eyedropper offer a visual route to the same result, while the copy buttons return CSS-ready values. CMYK ink bars, HSL, total ink coverage and a live swatch sit beside the hex code, so a colour can be checked for both screen and print without opening another tab. Every calculation runs in your browser, so nothing you type is uploaded or stored on a server. When you need the reverse operation, the HEX to RGB converter splits a hex code back into channels, and the HEX to CMYK converter takes the same colour into print territory.

FAQ

RGB to HEX questions, answered

Quick answers about converting RGB channel values to a hex color code, the formula, shorthand codes and round-trip accuracy.

How do I convert RGB to HEX?

Divide each channel by 16 to get the first hex digit, then use the remainder as the second digit, mapping 10 to 15 onto A to F. Do that for red, green and blue in order, join the three pairs and add a hash. For rgb(37, 99, 235) the pairs are 25, 63 and EB, so the RGB to HEX code is #2563EB.

What is the RGB to HEX formula?

For a channel value V, the high digit is floor(V ÷ 16) and the low digit is V mod 16, with both values written in base 16. Repeat for red, green and blue, then concatenate the pairs as #RRGGBB. Dividing by 16 and keeping the remainder is the whole RGB to HEX formula.

Can I convert RGB to HEX without an online converter?

Yes. The arithmetic is straightforward for a single colour: divide each channel by 16, note the quotient and remainder, and map any value from 10 to 15 to A through F. Most people reach for a converter when there are many colours to process, because a small slip in one channel changes the final hex code.

Why is my RGB to HEX code only three digits?

A three-digit code is valid shorthand only when both digits in each pair are identical, such as #FF6633 becoming #F63. Browsers expand it by doubling every digit. If any pair differs, as in #2563EB, the full six-digit form must be used because the shorthand cannot represent it.

Does converting RGB to HEX change the colour?

No. RGB and HEX are two notations for the same sRGB channel values, so converting between them is exact and reversible. A colour that goes from RGB to HEX and back again is unchanged. Differences appear only when you move to a different colour space, such as CMYK for print.

Is this RGB to HEX converter free and private?

Yes. The converter is free, needs no account and runs entirely in your browser. Nothing you type, pick or paste is uploaded to a server. The only data kept is your short list of recent colours in local browser storage, which you can clear at any time.