Skip to content
RightYantra
Text & developer

HEX to RGB Converter

Paste a HEX colour code to get its RGB values, with each pair of hex digits converted in front of you. It works the other way too: paste rgb(), rgba() or just three numbers to get the HEX code. Shorthand codes like #F80 and 8-digit codes with transparency are both understood.

How to use it· 4 steps
  1. Paste a hex code such as #1E90FF, 1e90ff, #F80 or #1E90FF80 — the # is optional.
  2. Read the RGB value at the top of the list, and the pair-by-pair breakdown showing how each channel was worked out.
  3. To go from RGB to HEX, paste rgb(30, 144, 255) or simply 30, 144, 255 into the same box.
  4. Use the opacity slider to add transparency, and copy the rgba() or 8-digit hex that results.
HEX to RGB ConverterRuns on your device

Step by step

How to use the hex to rgb converter

  1. 1Paste a hex code such as #1E90FF, 1e90ff, #F80 or #1E90FF80 — the # is optional.
  2. 2Read the RGB value at the top of the list, and the pair-by-pair breakdown showing how each channel was worked out.
  3. 3To go from RGB to HEX, paste rgb(30, 144, 255) or simply 30, 144, 255 into the same box.
  4. 4Use the opacity slider to add transparency, and copy the rgba() or 8-digit hex that results.

How a hex code stores red, green and blue

A six-digit hex colour is three numbers written side by side in base 16. #RRGGBB holds red in the first pair, green in the second and blue in the third, and each pair runs from 00 (none of that light) to FF (all of it). Because two hex digits make one byte, each channel has 256 levels, 0 to 255 — the same range rgb() uses.

To convert a pair, multiply the first digit by 16 and add the second, counting A to F as 10 to 15. For #1E90FF: 1E is 1 × 16 + 14 = 30, 90 is 9 × 16 + 0 = 144, and FF is 15 × 16 + 15 = 255. So #1E90FF is rgb(30, 144, 255), the CSS colour dodgerblue. The breakdown above the results shows this sum for every channel of whatever you paste.

RGB to HEX: the other direction

Going back, divide each channel by 16. The whole-number result is the first hex digit and the remainder is the second. 30 ÷ 16 is 1 remainder 14, giving 1E. 144 ÷ 16 is 9 remainder 0, giving 90. 255 is F remainder F. Join them with a # in front: #1E90FF.

Every channel must become exactly two digits. A channel value of 5 is 05, not 5, and forgetting the padding is the most common bug in hand-written converters: rgb(255, 5, 255) is #FF05FF, while the unpadded #FF5FF is an invalid five-digit code that browsers ignore. Paste three numbers into the box above and the padding is handled for you.

Channel values above 255 or below 0 do not exist in RGB. If you paste one, it is clamped to the nearest valid value and the result shows what was actually used.

Shorthand: #RGB and #RGBA

When each pair is a doubled digit, CSS lets you write each pair once. #F80 means #FF8800, #FFF is white and #000 is black. The expansion doubles each digit, it does not pad with zeros: #F80 is not #F08000.

Only colours whose pairs are all doubled have a shorthand. #1E90FF has none, because 1E is not a repeated digit, so the Short HEX row only appears when one exists. The 4-digit form #RGBA adds a shorthand alpha digit the same way: #F808 is #FF880088.

Alpha: 8-digit hex and rgba()

An eight-digit code adds a fourth pair for opacity: #RRGGBBAA. The alpha pair runs from 00, fully transparent, to FF, fully opaque, and converting it to the 0–1 value rgba() uses means dividing by 255. So #1E90FF80 has alpha 80 = 128, and 128 ÷ 255 = 0.502 — about half.

Useful pairs to remember: 100% is FF, 75% is BF, 50% is 80, 25% is 40 and 0% is 00. Because 255 does not divide evenly into a hundred steps, most percentages round to the nearest pair, which is why 50% comes back as 0.502 rather than exactly 0.5.

Watch the order on Android. Android's colour resources use #AARRGGBB, with alpha first, the reverse of CSS's #RRGGBBAA. A colour copied from an Android project into CSS with the alpha still at the front comes out as a completely different colour — #801E90FF in CSS is an opaque purple, rgb(128, 30, 144), not a half-transparent blue. Move the alpha pair to the end before pasting.

Other places these codes trip people up

In code, a colour is often written as a number with a 0x prefix, such as 0xFF1E90FF in Android or Flutter, where the first pair is again alpha. Drop the 0x, move the alpha pair to the end, and the remaining digits are a normal CSS hex code.

Case never matters — #1e90ff and #1E90FF are identical — and neither does the #, which is required in CSS but often missing in design-tool exports. Repeated conversions through HSL can shift a channel by one because HSL is rounded for display; converting HEX to RGB, as here, is exact both ways.

Answers

Frequently asked questions

How do I convert HEX to RGB?

Split the code into three pairs and convert each from base 16: first digit × 16 + second digit, with A–F as 10–15. #1E90FF becomes 1E = 30, 90 = 144, FF = 255, so rgb(30, 144, 255).

How do I convert RGB to HEX?

Divide each channel by 16; the quotient is the first hex digit and the remainder the second. Pad single digits with a leading 0. rgb(255, 5, 255) is #FF05FF. Paste the three numbers above and it is done for you.

What does an 8-digit hex code mean?

The last two digits are opacity, from 00 (transparent) to FF (opaque). #1E90FF80 is dodgerblue at 50% opacity, the same as rgba(30, 144, 255, 0.502).

What is #FFF in RGB?

rgb(255, 255, 255), white. A three-digit code doubles each digit, so #FFF is #FFFFFF and #F80 is #FF8800.

Why does my Android colour look wrong in CSS?

Android writes #AARRGGBB, with alpha first; CSS writes #RRGGBBAA, with alpha last. Move the first pair to the end before using it in CSS.