HEX to RGB Converter
Convert a color between HEX codes and RGB values in both directions.
Supports 6-digit and shorthand 3-digit HEX codes.
Updated August 14, 2026
Introduction / overview
The HEX to RGB Converter translates a color between the two formats you are most likely to meet in web and screen work: a hexadecimal code such as and an RGB triplet such as . Pick the direction you need, enter what you have, and the tool fills in the other side instantly.
Both directions work: start from a hex code or from red, green, and blue channels, and the tool recovers the same underlying color and converts it back the other way.
This is the tool you reach for whenever you have a color in one notation and need it in the other — a web developer copying a brand hex code out of a stylesheet and into CSS, a designer turning a hex value into RGB numbers for a design tool, or a student checking how the two notations relate. In HEX to RGB mode you can also switch on shorthand hex codes like , which CSS expands to . If your project calls for more formats at once, the Color Converter shows hex, RGB, HSL, HWB, CMYK, and color names side by side from one input.
How to use / quick start
Choose the direction
Under Conversion direction, pick HEX to RGB (the default) when you have a code, or RGB to HEX when you have channels.
Enter the color
HEX to RGB: type the hex digits — the is added for you. With Allow shorthand HEX notation enabled, use 3 digits such as FAB; otherwise use 6 such as FFA500. RGB to HEX: type whole numbers from 0 to 255 for R, G, and B.
Read the result
The other representation appears in the result box — an RGB triplet like in HEX to RGB mode, or a hex code like in RGB to HEX mode. Select the text to copy it straight into your code.
Example — hex #ffa500 becomes RGB 255, 165, 0
In HEX to RGB mode, type . The six digits are read in pairs — red, green, then blue:
The same orange is the color behind the CSS keyword orange.
Example — shorthand hex #FAB becomes RGB 255, 170, 187
In HEX to RGB mode, enable Allow shorthand HEX notation and type . Each digit is duplicated into a full pair, then read back as channels:
That is the same pink-purple you would get from the full code.
Calculation method
Both notations describe the same red, green, and blue intensities in the standard sRGB color model. A channel takes one of possible levels, from (off) to (full), and that range fits exactly into two hex digits.
Hex to RGB
A six-digit code is one 24-bit number . In practice you do not need the floor division — just read the code in pairs. For , the pairs are , , and , which are , , and .
RGB to hex
Each channel becomes two hex digits using , so is , is , and is . The three pairs are joined under one . Because each pair is exactly 8 bits, the whole code is one 24-bit number.
Shorthand hex codes
A 3-digit code duplicates each digit: , , . This is the official shorthand defined by the CSS Color Module Level 4, where hex codes take 3, 4, 6, or 8 digits and letter case does not matter. This tool accepts the 3- and 6-digit opaque forms; the 4- and 8-digit forms that add transparency are not supported here.
Variables
- — red, green, and blue channels (0–255)
- — the combined 24-bit value of the color
- — the two hex digits of a single channel
- — the base of hexadecimal notation
Frequently asked questions
Does the case of hex letters matter?
No. and are the same color in CSS, and the tool accepts either. The result box simply shows lowercase for a consistent readout.
Do I need to type the # myself?
No — the is shown as a fixed prefix on the input. Type only the digits, or paste a code that already includes the — both work.
Why can’t I enter a 4- or 8-digit code with transparency?
The 4- and 8-digit hex forms add an alpha (transparency) channel, which is outside the scope of a hex-to-RGB conversion. This tool converts opaque colors only, so it accepts the 6-digit form and, with shorthand enabled, the 3-digit form. For transparency, combine an opaque color with a CSS opacity value instead.
Limitations
This converter works with the standard 8-bit sRGB model used on screens. Hex codes must be 6 digits, or 3 digits when Allow shorthand HEX notation is enabled, and RGB channels must be whole numbers from to . Codes shorter or longer than the mode expects are rejected. The 4- and 8-digit forms with alpha are not supported, and how a color actually looks on your monitor depends on your display and color profile. A hex code is just a numeric recipe for a color — the tool converts that recipe faithfully but cannot guarantee two screens show it identically.
Related Calculators
Scale Calculator
Calculate scale factors and convert scaled or real dimensions for length, area, and volume.
Integer Base Converter
Convert an integer between bases 2–64 (binary, octal, decimal, hexadecimal, base64, and custom). Runs locally in your browser.
IPv4 address converter
Convert an IPv4 address into decimal, binary, hexadecimal, and IPv4-mapped IPv6 representations. Runs locally in your browser with one-click copy.
Roman Numeral Converter
Convert an Arabic number up to 3,999,999 into Roman numerals or read a Roman numeral back into a number. Both directions run in your browser.
Fraction to Percent Calculator
Convert fractions to percentages and vice versa instantly
Grams to Tablespoons Converter
Convert grams to tablespoons for any ingredient instantly. Perfect for cooking and baking with support for multiple ingredients.