You have a color in one format and a job that wants it in another. A stylesheet gives you #2563EB, but the tool in front of you asks for RGB values. The two formats look unrelated, one a jammed string of letters and digits, the other a tidy list of three numbers, so the conversion feels like a lookup you cannot do in your head.

It is simpler than it looks. HEX and RGB describe the same three amounts, and the HEX code is just those amounts written in a different number system. This guide converts with the free Color Picker on Ovatly, then takes the code apart pair by pair so you can see exactly where the RGB numbers come from.

Contents

  • Quick answer
  • Two number systems, one color
  • Reading a HEX code, pair by pair
  • How to convert with the Color Picker, step by step
  • Worked example: #2563EB, channel by channel
  • The 3-digit shorthand
  • Precision: why HEX and RGB never drift
  • Limitations and honest tradeoffs
  • Common mistakes
  • FAQs
  • Conclusion

Quick answer

Open the Color Picker, type your HEX value, and read the RGB line in the result panel. Copy it with its Copy button. The conversion is exact: #2563EB is rgb(37, 99, 235), every time you run it, because both formats hold the same three channel values. If you want to know where those numbers come from, each pair of the HEX code is one channel written in hexadecimal: 25 converts to 37, 63 converts to 99, and EB converts to 235.

Two number systems, one color

RGB lists three amounts: how much red, green and blue, each a decimal number. HEX packs the same amounts into a compact code for CSS: six characters in three pairs, one pair per channel in the same order.

The only real difference is the counting system. Decimal counts in tens. Hexadecimal counts in sixteens, using the digits 0 to 9 and then the letters A to F to stand for the values 10 to 15. A pair of hexadecimal digits can therefore hold any value a channel needs, and converting a color means converting three small numbers.

Reading a HEX code, pair by pair

Take #2563EB and split it after the #: 25, 63, EB. The first pair is the red amount, the second is green, the third is blue.

Each pair converts with the same move: multiply the first digit by 16, then add the second digit. For red, 2 times 16 plus 5 is 37. For green, 6 times 16 plus 3 is 99. For blue, the letters do the work: E stands for 14 and B stands for 11, so 14 times 16 plus 11 is 235. Line the three results up and you have rgb(37, 99, 235), exactly the RGB line the Color Picker shows for this color. The tool does this arithmetic for you; knowing it turns a HEX code from a random string into three amounts you can read at a glance.

How to convert with the Color Picker, step by step

  1. Open the Color Picker and type your HEX value into the field, for example #2563EB. You can also pick a color with the swatch, your operating system's own picker, and the tool will show its HEX.
  2. Read the result panel: the color in all three notations the web actually uses, HEX, RGB and HSL, next to a large preview.
  3. Copy the notation you need with its Copy button, so no digit gets mistyped on the way into your stylesheet, design file or document.
  4. Before using the color for text, glance at the contrast ratios the tool shows against black and white. A converted color is not automatically a readable one.

Worked example: #2563EB, channel by channel

Here is the full conversion of the blue used throughout this guide, pair by pair:

  • Red: the pair 25. 2 times 16 is 32, plus 5 is 37. Red is 37.
  • Green: the pair 63. 6 times 16 is 96, plus 3 is 99. Green is 99.
  • Blue: the pair EB. E is 14, so 14 times 16 is 224. B is 11, so 224 plus 11 is 235. Blue is 235.

Put together: rgb(37, 99, 235). The Color Picker also shows this color as hsl(221, 83%, 53%), and reports its contrast as 5.17:1 against white, which passes the WCAG AA minimum of 4.5:1 for normal text, and 4.06:1 against black, which does not. So the same panel that converts the color also tells you where it belongs: this blue suits light backgrounds, not dark ones.

The 3-digit shorthand

Not every HEX code has six characters. The picker accepts 3 or 6 characters of 0-9 and A-F, optionally starting with #. The 3-digit form is a shorthand: each single character covers both positions of its pair, so #FFF expands to #FFFFFF and #000 to #000000. Only colors whose pairs happen to be doubled digits can be written this way, which is why most real-world colors you meet are the full six characters.

Precision: why HEX and RGB never drift

HEX and RGB are always exact, because neither one rounds anything: they are the same three whole numbers in two notations, and converting between them loses nothing in either direction. You can convert a color back and forth all day and land on the identical values.

HSL is the exception in the panel. Its values are rounded to whole numbers, so converting back from HSL can differ by one unit in a channel. That makes HSL the notation to adjust a color by eye with, since hue, saturation and lightness are easy to nudge, and HEX or RGB the notation to record the final color in.

Limitations and honest tradeoffs

The picker is strict about input. A valid HEX is 3 or 6 characters of 0-9 and A-F, optionally starting with #. Anything else is rejected: color names do not work here, and neither do rgb() strings, even though both describe colors fine elsewhere. If your color currently exists as a name or an rgb() string, you need its HEX first.

The swatch can also show you more than the page does. Because the swatch is your operating system's picker, it may offer extra formats that this page does not display. The panel itself sticks to the three notations the web actually uses: HEX, RGB and HSL. And the tool works on one color at a time; for a pair of colors of your own choosing, you would check them against each other rather than against black or white alone.

Common mistakes

  • Typing a color name. Names like "blue" are invalid input here. The picker needs a HEX value or a swatch pick.
  • Pasting an rgb() string. The format rgb(37, 99, 235) is an output of this tool, not an input. Type the HEX instead.
  • Dropping or adding a character. Five or seven characters is neither form, so the code shows as invalid. Count the characters.
  • Reading the pairs in the wrong order. The pairs are always red, green, blue. Swap the first and third pairs and you have described a different color.
  • Treating HSL as exact. HSL is rounded to whole numbers. Record final colors as HEX or RGB, which never drift.

FAQs

What does each pair in a HEX code stand for? Each pair is one channel: the first pair is the red amount, the second is green and the third is blue. In #2563EB the pairs are 25, 63 and EB, written in hexadecimal, which is why they convert to 37, 99 and 235 in decimal.

Why does #2563EB read as rgb(37, 99, 235)? Because each pair converts separately. 25 in hexadecimal is 2 times 16 plus 5, which is 37. 63 is 6 times 16 plus 3, which is 99. EB is 14 times 16 plus 11, because E stands for 14 and B for 11, which gives 235.

Is a 3-digit HEX code valid? Yes. The Color Picker accepts 3 or 6 characters of 0-9 and A-F, optionally starting with #. The 3-digit form is a shorthand where each character covers both positions of its pair, so #FFF is the short way of writing #FFFFFF.

Can I type a color name or an rgb() string into the picker? No. Color names and rgb() strings are invalid input here. The picker takes a HEX value typed in, or a color chosen with the swatch, and then shows you the HEX, RGB and HSL notations for it.

Is the conversion between HEX and RGB exact? Yes. HEX and RGB are always exact, because they hold the same three channel values in two number systems. HSL is rounded to whole numbers, so converting HSL back can differ by one unit in a channel.

Conclusion

A HEX code is three RGB amounts wearing a compact disguise, and once you can split it into pairs the disguise falls away: multiply the first digit of each pair by 16, add the second, and the RGB values are in front of you. The Color Picker does that arithmetic instantly and hands you all three notations with copy buttons, plus a contrast check for text use. Capturing a color in the first place is a different job, covered in our sibling guide on picking a color from a website you like. For more guides in this series, see the Color and Design Tools guides.