HEX to RGB

Turn any HEX code into its rgb() value instantly, ready to copy for CSS or code.

1
Step one — Paste your HEX value
Also accepts a three-digit hex like #16F.
2
Step two — Your RGB color
3
Step three — The same color, every format

Steps to convert HEX to RGB

  1. Paste your hex code into the field, with or without the leading hash.
  2. Read the rgb() value that appears straight away.
  3. Click it to copy, ready for CSS, canvas or any RGB input.
  4. Need the alpha channel too? Carry on to RGBA.

How HEX to RGB conversion works

A hex code is just RGB written in base 16, so the conversion is a straight rewrite rather than a calculation that loses anything. Each of the three pairs becomes one channel from 0 to 255:

HEX pairChannelBase-16Decimal
1ERed1×16 + 1430
90Green9×16 + 0144
FFBlue15×16 + 15255
Worked example: #1E90FF becomes rgb(30, 144, 255). The reverse trip is just as easy with RGB to HEX.

HEX and RGB compared

HEXRGB
Looks like#1E90FFrgb(30, 144, 255)
Base16 (hex)10 (decimal)
LengthCompactLonger, readable
Best inCSS, brand guidesCode, canvas, APIs

Why developers convert HEX to RGB

Designers hand over hex codes, but a lot of code cannot use them directly, and that gap is the whole reason this conversion is so common. The moment you need to animate a single channel, mix colors in JavaScript, or add transparency, separate 0 to 255 numbers are far easier to work with than a packed hex string. Keeping the hex for your stylesheet and the rgb() for your scripts is the practical habit.

What HEX to RGB is used for

  • Feeding a color into canvas or WebGL, which expect numeric channels.
  • Talking to an RGB-only API or hardware, like an LED strip.
  • Building an rgba() value when you need to add opacity.
  • Reading a color’s channels to tweak just one of them in code.

How to convert HEX to RGB in JavaScript

In code the conversion is three slices and a base-16 parse, which is why developers often inline it rather than reach for a library:

const r = parseInt(hex.slice(1, 3), 16); const g = parseInt(hex.slice(3, 5), 16); const b = parseInt(hex.slice(5, 7), 16); — for #1E90FF that yields 30, 144, 255. Each channel runs 0 to 255, giving 256 × 256 × 256, or 16,777,216 possible colors.
Does #1E90FF equal rgb(30, 144, 255)?

Yes, exactly. HEX is RGB written in base 16, so they are the same color.

What about a three-digit hex code?

A short code like #1AF expands by doubling each character to #11AAFF first, then converts as normal.

How do I convert an 8-digit hex with alpha?

The first six digits give RGB as usual; the last pair is the alpha. Divide it by 255 for the 0 to 1 opacity, so #1E90FF80 is rgba(30, 144, 255, 0.5).

Is any color lost converting HEX to RGB?

No. Both describe the same 0 to 255 channels, so the conversion is exact in both directions.

Can I convert several hex codes at once?

This tool handles one at a time; for many colors, convert each or use the full Color Converter.

You might also like