HEX to RGB Converter

Turn a hex color into its red, green and blue numbers — and the CSS rgb() string — exactly and instantly.

Color ToolsPopular Free No upload Instant

Loading HEX to RGB Converter…

Your browser is preparing the tool. It runs 100% locally.

Quick Answer

Paste a hex color such as #8B5CF6 and this returns its red, green and blue values — 139, 92, 246 — plus the ready-to-use CSS string rgb(139, 92, 246). Each hex pair is just one 0–255 channel written in base 16, so the conversion is exact and instant, and three-digit shorthand like #F90 is expanded automatically before converting.

What the HEX to RGB Converter Does

Type a hex color and the tool shows its three RGB channels as decimal numbers from 0 to 255, plus the CSS rgb() string you can paste straight into a stylesheet. It accepts the full six-digit form and the three-digit shorthand, with or without the #, and it repaints a swatch and recalculates on every keystroke. It opens on #8B5CF6 as a worked example.

Decimal RGB is what you reach for when a hex token won't do: a canvas or WebGL call, an image library in Python or JavaScript, a spreadsheet that builds colors from numbers, a game engine, or an rgba() value where you want the channels separate from the opacity.

How It Works

A hex color is nothing more than RGB written in base 16. The six digits are three pairs — one for red, one for green, one for blue — so the tool strips the #, expands any three-digit shorthand to six, then reads each pair as a number from 0 (written 00) to 255 (written FF).

Because that mapping is exact, there's no color science and no rounding involved: #8B5CF6 always comes back as precisely 139, 92, 246. The whole thing recomputes locally on every keystroke, and feeding the result into the RGB-to-HEX tool returns the original hex untouched.

Data source & conversion logic

There's no color data to fetch. The conversion is defined entirely by how hex notation encodes an sRGB color — each two-digit pair is one 8-bit channel in base 16 — so the work is pure arithmetic done in the page.

  1. Step 1. Remove the leading # if it's there.
  2. Step 2. If the value is a three-digit shorthand, expand each digit to a pair (F to FF, 9 to 99).
  3. Step 3. Split the six digits into three pairs: red, green, blue.
  4. Step 4. Read each pair as a base-16 number, giving a 0–255 value per channel.
  5. Step 5. Show the three numbers, assemble the CSS rgb() string, and preview the swatch.

Hex to RGB

#RRGGBB → R = base16(RR), G = base16(GG), B = base16(BB) (each pair runs 00–FF, i.e. 0–255 in decimal)
Worked examples
#8B5CF6 → 8B = 139, 5C = 92, F6 = 246 → rgb(139, 92, 246)
#F90 → expands to #FF9900 → rgb(255, 153, 0)

FF is the largest two-digit hex value, 255 in decimal; 00 is the smallest, 0. Each channel spans the full 0–255 range, which is why the conversion is exact and reversible.

Technical Details

InputHex #RRGGBB or #RGB shorthand
OutputR, G, B (0–255) plus CSS rgb()
ConversionExact, base-16 to decimal
Channels8-bit, 0–255 each
ShorthandThree-digit hex expanded automatically
HashOptional — # added if you omit it
AlphaEight-digit #RRGGBBAA not parsed
Where it runsIn your browser, live

Standards & references

  • sRGB hex notation — every two-digit pair in #RRGGBB is one 8-bit channel (00–FF maps to 0–255), as defined for sRGB and CSS hex colors.
  • CSS Color — rgb() — the rgb() string the tool outputs is the standard CSS functional notation, valid in any stylesheet.
  • 24-bit truecolor — three 8-bit channels give 16,777,216 possible colors — the range a six-digit hex can describe.

Accuracy & Limitations

The conversion is exact and fully reversible, because hex and RGB are two notations for the same 8-bit sRGB value — there's no rounding to introduce drift. Run the output back through RGB to HEX and you get the original hex.

It expects a three- or six-digit hex. An eight-digit hex carrying alpha (#RRGGBBAA) or a named color won't parse and shows an 'invalid input' notice — strip the alpha pair first, or read it separately as opacity.

Values are interpreted as sRGB. A hex copied out of a wide-gamut (Display P3) workflow is converted as plain sRGB numbers here, not remapped to that gamut.

Real-World Use Cases

Canvas, WebGL and game engines

Get the raw 0–255 channels these APIs expect, instead of passing a hex string they can't read directly.

Building rgba() with opacity

Take the three RGB numbers and add your own alpha to make a semi-transparent rgba() color.

Image scripts and libraries

Feed integer RGB into Python, JavaScript or other image-processing code that works in numbers, not hex.

Spreadsheets and data viz

Drive conditional formatting or chart colors that are defined by numeric channels rather than a hex token.

When to use it — and when not to

Good for

  • Turning a CSS or design hex into numeric RGB
  • Feeding 0–255 channels to canvas, scripts or engines
  • Building an rgba() color with custom opacity
  • Checking what a hex equals in plain numbers

Not the best choice for

  • Going the other way, from numbers to hex
  • Adjusting hue, saturation or lightness
  • Parsing an eight-digit hex with an alpha pair

Need the reverse? Use RGB to HEX. Want to adjust a color by hue or lightness? Convert it to HSL. Working with an alpha hex? Drop the last pair here and treat it as opacity separately.

Frequently Asked Questions

How do I read a hex color as RGB?
Split the six digits into three pairs — red, green, blue — and read each pair as a base-16 number from 00 (0) to FF (255). The tool does this for you and also writes out the CSS rgb() string.
Does it accept three-digit shorthand like #F90?
Yes. Each shorthand digit is doubled to make a full pair, so #F90 becomes #FF9900 and converts to rgb(255, 153, 0). The result is identical to typing the long form.
Do I need to include the # symbol?
No. The tool strips a leading # if it's present and works fine without one, so 8B5CF6 and #8B5CF6 give the same result.
What about an eight-digit hex with alpha (#RRGGBBAA)?
That isn't parsed — the tool handles three- and six-digit hex only and will flag an eight-digit value as invalid. Remove the final alpha pair to convert the color, and treat that pair separately as opacity if you need it.
Is the conversion exact, or is there rounding?
It's exact. Hex and RGB are the same 8-bit value in two notations, so nothing is approximated. Convert the result back with RGB to HEX and you'll recover the original code.
What's the difference between the three numbers and the rgb() string?
They're the same data. The three numbers are the bare channels (139, 92, 246); the rgb() string wraps them in CSS functional notation, rgb(139, 92, 246), ready to paste into a stylesheet.
Why convert hex to RGB at all?
Because plenty of contexts can't take a hex string: a canvas or WebGL call, an image library, a spreadsheet, a game engine, or an rgba() value where you want the channels separate from the alpha. Those all want decimal RGB.
What's the maximum value for a channel?
255, written FF in hex. The minimum is 0, written 00. Each of the three channels covers that full 0–255 range, which is what gives 24-bit color its 16.7 million combinations.
Does the letter case of the hex matter?
No. Hex is case-insensitive, so #8b5cf6 and #8B5CF6 convert to exactly the same RGB values.
Does #FFFFFF really equal rgb(255, 255, 255)?
Yes — that's white, every channel at its maximum. Likewise #000000 is rgb(0, 0, 0), pure black, with every channel at zero.
Is my color uploaded anywhere?
No. The conversion is pure arithmetic that runs in your browser; nothing you type leaves your device.
What color space does it assume?
sRGB, the standard space a hex or rgb() value implies on the web. It doesn't remap wide-gamut colors — those are read as ordinary sRGB numbers.

References

A hex color is RGB written in base 16, so this conversion is exact and reversible — feed the result back through RGB to HEX and you land on the original code.

PopularHot

Color Picker

Use Color Picker to choose and convert color precisely — instant and free.

ColorOpen Tool
Trending

Color Palette Generator

Use Color Palette Generator to choose and convert color precisely — instant and free.

ColorOpen Tool
Trending

Gradient Generator

Use Gradient Generator to choose and convert color precisely — instant and free.

ColorOpen Tool
Editor's Pick

Contrast Checker

Use Contrast Checker to choose and convert color precisely — instant and free.

ColorOpen Tool

RGB to HEX Converter

RGB to HEX Converter with copy-ready values for design and front-end work.

ColorOpen Tool

HEX to HSL Converter

HEX to HSL Converter online — accurate color values, palettes and previews in-browser.

ColorOpen Tool

Ready to try the HEX to RGB Converter?

It is free, private and runs entirely in your browser — no sign-up, no uploads, no limits.