🎨

HEX to RGB

✓ Free & no signup 🔒 Runs 100% in your browser Updated 2026-11-25 Other Tools
—
Red
—
Green
—
Blue
—
CSS

Design files speak hexadecimal, JavaScript and canvas APIs speak decimal, and the gap between the two is where small mistakes happen — a channel read as 52 instead of 219 produces a color nobody asked for. This tool converts hex color codes to RGB values instantly: type or paste a hex code, and the red, green, and blue channel values appear live alongside the CSS rgb() string and a swatch of the exact color, all computed in your browser with nothing sent anywhere.

The page is deliberately narrow. Where a general color converter juggles four notations, this one does one job thoroughly: it parses messy real-world input (with or without the hash, in upper or lower case), expands three-digit shorthand automatically, reads the eight-digit RGBA form that includes transparency, and explains the arithmetic so you can verify any conversion by hand afterward. If you work with web colors often, understanding this one mapping — hex pairs to decimal channels — demystifies most of what follows in color handling.

What Hex and RGB Actually Represent

A six-digit hex code is three bytes written in hexadecimal: the first pair is the red channel, the second green, the third blue. RGB is the same three numbers in decimal, each from 0 to 255. Both notations describe identical values — 8 bits per channel, 24 bits total, roughly 16.77 million possible colors, which is what the phrase 24-bit color or truecolor means.

A worked example ties them together. Take #1A2B3C: the red byte is 1A, and 1A in hex means 1 times 16 plus A times 1, where A stands for 10 — giving 26. The green byte 2B is 2 times 16 plus 11, giving 43. The blue byte 3C is 3 times 16 plus 12, giving 60. So #1A2B3C converts to rgb(26, 43, 60), a very dark navy. Reverse-checking is fast: 43 divided by 16 is 2 remainder 11, and 11 in hex is B, hence 2B.

How to Use This Tool (Step by Step)

  1. Paste or type the hex code into the input. The hash is optional — the tool accepts 1A2B3C and #1A2B3C identically, and case never matters.
  2. Read the three channel values and the ready-to-paste rgb() string from the result panel.
  3. Check the swatch to confirm the parsed color is the one you intended — a caught misparse costs nothing, a deployed one does not.
  4. Try the three-digit shorthand form, like #F53, which expands to FF5533 before conversion.
  5. For transparency, paste an eight-digit code such as #FF573380; the final pair is reported separately as the alpha value, 80 hex being 128 decimal, or 50 percent opacity.

Three-Digit Shorthand and How Expansion Works

CSS allows a compact form where each digit is doubled: #F53 becomes #FF5533. The rule is mechanical repetition — the red digit F becomes FF, the green 5 becomes 55, the blue 3 becomes 33. That yields rgb(255, 85, 51), a strong coral red. Shorthand only expresses colors whose two hex digits per channel are identical, which is 4,096 of the 16.77 million colors — but those include the everyday workhorses like #000, #FFF, and #333, which is why minifiers and hand-written CSS lean on it. The expansion is lossless: a color written short-form converts to exactly the same RGB as its long form.

The Eight-Digit Form: Hex With Alpha

The modern CSS spec extends hex to four pairs, the last describing opacity. Each step of alpha halves or doubles actual visibility in the same binary way channels do — and the mapping is linear, so 80 hex is exactly 128 decimal, half opacity, while 40 hex is 64 decimal, a quarter opacity, and FF is fully opaque. This tool reports the alpha channel separately so the RGB conversion stays clean: #FF573380 reads as the same coral color at half opacity. Older tooling that predates the syntax will reject eight-digit codes outright, so check what your destination accepts before standardizing on the form.

Conversion Examples You Can Verify by Hand

HexRedGreenBluergb() string
#FF57332558751rgb(255, 87, 51)
#1A2B3C264360rgb(26, 43, 60)
#7F7F7F127127127rgb(127, 127, 127)
#F53 (expands to FF5533)2558551rgb(255, 85, 51)
#FFFFFF255255255rgb(255, 255, 255)
#000000000rgb(0, 0, 0)

The gray row is worth a second look: 7F hex is 127 decimal, one below half brightness — the nearest a byte gets to 50 percent. That off-by-one appears constantly in gradients and is a classic source of why the middle stop of a CSS gradient does not look exactly half-way between its endpoints.

Where Hex-to-RGB Conversion Goes Wrong

  • Five-digit input: neither shorthand nor long form — almost always a lost character in transit. The tool flags the length rather than guessing.
  • Non-hex characters: letters beyond F, stray quotes from copying out of a stylesheet, or a colon riding along from JSON. The parser names the offending character.
  • Percent confusion: rgb can legally be written with percentages — rgb(100%, 50%, 0%) — but hex cannot; there is no percent form of a hex pair, and mixing the mental models produces values like 100 in a channel where 255 was meant.
  • Wrong pair boundaries: reading 1A2B3C as channels 1A2, B3C is a common beginner slip; the format is strictly two digits per channel.
  • Alpha misread as blue: pasting an 8-digit code into a converter that only reads 6 digits yields a wrong blue channel from the alpha pair — this tool separates the last pair out instead.

Practical Uses in Daily Work

Several routine tasks reduce to this conversion. Reading a color out of a design export and applying it in JavaScript — canvas fill styles, WebGL uniforms, chart libraries — needs decimal channels. Computing color math like blending, darkening, or contrast ratios operates on numeric channels, not text. Debugging a rendering mismatch between a mockup and a live page starts by converting both sides to the same notation and comparing channel by channel. And accessibility work converts colors to RGB first because the WCAG contrast formula consumes linearized channel values. In each case the swatch closes the loop: convert, glance, confirm.

Tips and Best Practices

  • Keep brand colors in hex as the single source of truth and convert to RGB at the point of use, rather than maintaining parallel definitions.
  • Use the swatch as a parse check every time — especially after pasting from documents where invisible characters sneak in.
  • Remember 00 is black-channel-off and FF is full-on; mentally anchoring those two makes any hex code readable at a glance.
  • For opacity in CSS, prefer rgba() or 8-digit hex consistently, and know that 80 is the exact midpoint value.
  • The conversion is pure math running locally — colors from unreleased designs can be checked here without leaving your machine.

Frequently Asked Questions

How do I convert a hex color to RGB?
Split the six digits into three pairs and convert each pair from hexadecimal to decimal. For #FF5733: FF is 255, 57 is 87, and 33 is 51, giving rgb(255, 87, 51). The mental math is tens and ones in base 16 — the digit 57 means 5 times 16 plus 7. This tool does it instantly and safely: paste the code, read the three channel values and the ready-to-use rgb() string, and confirm with the live swatch that the parsed color is the one you intended.
What does the # symbol mean in hex color codes?
Nothing functional — it is notation marking the following characters as a hex number, borrowed from CSS syntax. The tools treat #FF5733 and FF5733 as identical input, and case is equally irrelevant: ff5733 and FF5733 parse to the same values. The hash does matter as a delimiter in stylesheets and design files, where it distinguishes a color from surrounding text, which is why copying a color out of a JSON config or URL may hand you the bare digits instead. Both forms convert identically here.
Why do some hex codes have only 3 digits?
That is CSS shorthand: each digit is doubled to form the full code, so #F53 expands to FF5533, which converts to rgb(255, 85, 51). Only colors whose channels repeat a digit — like #333 becoming 333333 — can be written short-form, about 4,096 of the 16.77 million possible colors, but that set includes the most-used workhorse grays and primaries. The expansion is lossless and standard across browsers. This tool accepts the shorthand automatically and shows you the expanded code before converting, so nothing happens invisibly.
How do I read the alpha channel in an 8-digit hex color?
The first six digits are the usual red, green, and blue pairs; the final two digits describe opacity on the same 0-to-255 scale. #FF573380 is the coral color FF5733 at alpha 80 hex, which is 128 decimal — exactly half opacity. Other checkpoints: FF is fully opaque, 40 is a quarter, C0 is about three-quarters. Not all tooling supports the form — it arrived in CSS with the modern color spec, and older converters reject eight digits outright. This tool reads the alpha pair separately so it never contaminates your blue channel.
Why does my converted color look slightly different in the design file?
Hex-to-RGB conversion itself is exact — the same numbers either way — so differences come from elsewhere. The usual suspects: a color profile mismatch between design software and browser, where the same RGB renders through different color management; transparency baked into the design that a flat swatch hides; or the color being displayed on a dark versus light background, which shifts perception without changing values. Convert both sides to RGB and compare channels: if the numbers match, the discrepancy is display-level, not a data error.
What is the largest value a hex color channel can have?
255 decimal, written FF in hex. Each channel is one byte — 8 bits — so values run from 00 (0, the channel fully off) to FF (255, fully on). That ceiling is why 256 appears constantly in color code: 256 possible values per channel, three channels, 16,777,216 total colors. Values beyond FF are invalid in standard sRGB hex, and this tool rejects them explicitly rather than wrapping around. The same byte scale explains the alpha channel in 8-digit codes and why FF is full opacity rather than 100 in some other unit.

Related Tools