HEX to RGB Converter

HEX to RGB: #1E90FF = rgb(30, 144, 255). See the formula worked step by step, a reference table, and our test of every HEX value.

How to use HEX to RGB

  1. 1Paste a HEX code: with or without #, 3 or 6 digits (#1E9 or #1E90FF).
  2. 2Read the three channel values in the RGB field.
  3. 3Copy rgb(30, 144, 255) style output straight into CSS, or the bare numbers into code.

Features

  • Accepts shorthand, uppercase and lowercase codes
  • Exact: all 16,777,216 codes round-trip unchanged
  • CSS named-colour reference with both notations

How HEX to RGB conversion works

A HEX code is not a different colour model at all: it is the same three RGB channels written in base 16. Each pair of digits is one channel, and each pair can hold 16 × 16 = 256 values, which is why RGB channels run from 0 to 255. Converting is just reading each pair as a number.

  • Drop the # and expand shorthand: #1E9 becomes #11EE99 (each digit doubled).
  • Split into three pairs: red, green, blue.
  • For each pair, value = (first digit × 16) + second digit, where A = 10, B = 11 … F = 15.
  • Write the result as rgb(R, G, B).

Worked example: #1E90FF to RGB

Here is the converter's own calculation for #1E90FF, step by step. The result, rgb(30, 144, 255), is exactly what the tool above shows for this input.

  • Split into pairs: 1E, 90, FF.
  • Red: 1E = 1 × 16 + 14 = 30.
  • Green: 90 = 9 × 16 + 0 = 144.
  • Blue: FF = 15 × 16 + 15 = 255.
  • Written as rgb(30, 144, 255).

CSS named colours in HEX and RGB

Sixteen of the 148 named colours defined in CSS, with the HEX code the specification assigns to each.

ColourHEXRGB
dodgerblue#1E90FFrgb(30, 144, 255)
tomato#FF6347rgb(255, 99, 71)
rebeccapurple#663399rgb(102, 51, 153)
steelblue#4682B4rgb(70, 130, 180)
coral#FF7F50rgb(255, 127, 80)
gold#FFD700rgb(255, 215, 0)
seagreen#2E8B57rgb(46, 139, 87)
slategray#708090rgb(112, 128, 144)
crimson#DC143Crgb(220, 20, 60)
teal#008080rgb(0, 128, 128)
orchid#DA70D6rgb(218, 112, 214)
darkorange#FF8C00rgb(255, 140, 0)
navy#000080rgb(0, 0, 128)
lavender#E6E6FArgb(230, 230, 250)
chocolate#D2691Ergb(210, 105, 30)
turquoise#40E0D0rgb(64, 224, 208)

Source: W3C CSS Color Module Level 4

Precision test: every HEX value through the converter

HEX to RGB is the one conversion on this site that can never lose anything: we ran all 16,777,216 HEX codes through the converter and back, and 100% returned identical. The two notations hold exactly the same information, so pick whichever the destination expects.

Method: every whole-number HEX value, through the converter's own code and back, compared on the 0–255 scale (how we test).

MeasureResult
HEX values tested16,777,216
Distinct RGB results16,777,216
Came back exactly100%
Largest change (0–255 levels)0
Average change0

Last updated · Source: Pixohub exhaustive test of lib/color-math.ts

Where you'll use HEX to RGB

Canvas and JavaScript drawing

Canvas getImageData() returns raw 0–255 channel values, and libraries such as Three.js or p5.js often take separate red, green and blue numbers. Converting the HEX from a style guide gives you those numbers directly.

Adding transparency in CSS

Designers hand over #1E90FF; for a 40% overlay you need rgb(30 144 255 / 0.4). You can also write the alpha in HEX as an eighth and ninth digit (#1E90FF66), but the rgb() form is easier to read and edit.

Hardware and LED projects

Arduino, WLED and smart-bulb APIs usually take three 8-bit integers. The HEX value from a colour picker maps one-to-one onto those, with no rounding.

Common mistakes

  • Treating a 3-digit code as padded rather than doubled: #F80 is #FF8800, not #F80000.
  • Reading an 8-digit code as RGB: in #1E90FF80 the last pair is alpha (128 ≈ 50% opacity), not part of the colour.
  • Assuming RGB numbers are percentages: rgb(30, 144, 255) uses 0–255. CSS also accepts rgb(12% 56% 100%), which is a different scale for the same colour.
  • Mixing up channel order from code that stores colours as BGR (Windows GDI's COLORREF and OpenCV both do); the numbers are right but red and blue swap.

Frequently asked questions

How many HEX codes have a 3-digit shorthand?

4,096. Shorthand works only when both digits of every pair match (#FF8800 → #F80), so 16 × 16 × 16 of the 16,777,216 colours qualify.

Is #1E90FF the same as the CSS name dodgerblue?

Yes. dodgerblue is one of the 148 CSS named colours and is defined as #1E90FF, which is rgb(30, 144, 255). The table on this page lists more named colours with both values.

Does HEX to RGB lose any precision?

No. We tested every one of the 16,777,216 HEX codes: all of them convert to RGB and back unchanged, because both notations store the same three 8-bit numbers.

Are HEX codes case-sensitive?

No. #1e90ff and #1E90FF are the same colour in CSS, HTML and every design tool we know of; uppercase is just a convention.

More text, code & dev tools