ARYXTOOLS

Free Online Tools

ARYXTOOLS

Hex to RGB Converter

Convert hex color codes to RGB and back instantly, with alpha support and a contrast checker.

HEX

#7C5CFC

RGB

rgb(124, 92, 252)

Contrast ratio

On white background

4.38:1

Passes AA for large text only

On black background

4.79:1

Passes AA for normal text

Quick reference

#FFFFFF→rgb(255, 255, 255)
#000000→rgb(0, 0, 0)
#FF5733→rgb(255, 87, 51)

More color tools

Every color you have ever picked in a design tool exists as a hex code and an RGB value at the same time. They are not two different colors, they are two different spellings of the same one. Designers tend to think in hex because it is compact and easy to paste. Developers writing canvas or WebGL code often need RGB because the channels are plain integers you can add, subtract, and animate. This tool moves between the two instantly, in both directions, with alpha transparency and a contrast checker built in.

What this tool does

Paste a hex color code and get the matching RGB values immediately, or enter red, green, and blue numbers and get the hex code back. Both 3-digit shorthand hex (like #7CF) and 8-digit hex with an alpha channel are accepted, beyond the standard 6-digit format. The tool shows a live color swatch so you can see the actual color before committing to it in your code, and it calculates the WCAG contrast ratio of that color against both white and black backgrounds, which tells you whether text in that color will will be readable.

How to use it, step by step

  1. Choose a direction: "Hex to RGB" if you are starting from a hex code, or "RGB to Hex" if you already have red, green, and blue numbers.
  2. For hex input, paste the code with or without the leading #. Shorthand codes like #7CF expand automatically to the full 6-digit value.
  3. For RGB input, type each channel as a number from 0 to 255 in its own field.
  4. The color swatch, hex value, and RGB value update immediately. Each value has its own copy button.
  5. If the hex code includes an 8-digit alpha channel, an RGBA value appears below the plain RGB result with its own copy button.
  6. Check the contrast ratio section to see whether this color, used as text, would pass WCAG AA accessibility standards on a white or black background.

Who this is for

Web designers moving a color from a design tool like Figma into CSS use this to get the exact rgb() syntax a stylesheet expects. Frontend developers working with canvas, WebGL, or any API that wants numeric color channels instead of a hex string use the reverse direction constantly. Accessibility-conscious developers use the contrast checker to confirm text and background color combinations meet WCAG AA before shipping a design. Anyone debugging a color that looks wrong on screen can paste the hex value here and see precisely which of the three channels is off.

What hex and RGB represent

RGB is one of several models computers use to build color out of light instead of pigment. Every color on a screen is made from three overlapping beams: red, green, and blue. Each beam can sit anywhere from fully off to fully on, represented as an integer from 0 to 255. Mix all three at full intensity and you get white. Mix none and you get black. Everything else is a combination of the three.

Hex is not a different color model, it is a different way of writing the same RGB values. Instead of three decimal numbers separated by commas, hex concatenates three two-digit hexadecimal numbers into one string, prefixed with a #. The structure is #RRGGBB. Each pair, RR, GG, and BB, is a hexadecimal number from 00 to FF, which covers the same 0 to 255 range as RGB, written in base 16 instead of base 10.

Converting hex to RGB by hand

Take the hex code #4CAF50, a common green used in Material Design. Split it into three pairs: 4C, AF, 50. Each pair is a base-16 number. 4C in hex is 76 in decimal. AF in hex is 175 in decimal. 50 in hex is 80 in decimal. Write those three numbers in order and you get rgb(76, 175, 80).

If you want the arithmetic behind converting a hex pair to decimal rather than trusting the tool blindly, this is the same base conversion the binary to decimal converter explains in more depth, with a base of 16 instead of 2. The first hex digit represents multiples of 16, the second represents single units, and adding them together gives the decimal value.

Converting RGB to hex by hand

Going the other way, take each RGB channel and convert it to a two-digit hexadecimal number. For rgb(255, 87, 51): 255 in hex is FF. 87 in hex is 57. 51 in hex is 33. Concatenate them with a # prefix and you get #FF5733.

Values under 16 need a leading zero to keep every pair at exactly two digits. The decimal number 5, for example, is "5" in hex, but it has to be written as "05" in a hex color code, since #05... has to occupy the same two character slot as every other channel. Skipping the leading zero produces an invalid or misread color code, which is a common source of colors that look subtly wrong after a manual conversion.

Shorthand hex and why it works

Three-digit hex codes like #7CF are shorthand for six-digit codes where each digit repeats. #7CF expands to #77CCFF, not #700C0F0. Each character in the short form doubles into a pair in the long form. This only works when both digits in each pair would be identical, so shorthand can represent a limited subset of all possible colors, but it covers a lot of common flat design colors and shows up constantly in CSS written by hand.

Eight-digit hex codes add a fourth pair for alpha transparency, following the same pattern as the RGB channels: 00 is fully transparent, FF is fully opaque. This tool reads that fourth pair and converts it to a decimal alpha value between 0 and 1 for the RGBA output, since that is the format CSS and most graphics libraries expect.

Why the contrast ratio matters

A color that looks fine to you might be unreadable to someone with low vision, or unreadable to anyone on a washed-out laptop screen outdoors. The Web Content Accessibility Guidelines define a mathematical contrast ratio between two colors, calculated from their relative luminance, and set minimum thresholds for text to be considered accessible. A ratio of 4.5:1 or higher is required for normal-sized text to pass WCAG AA, the most commonly targeted standard. Large text, 18pt or larger, needs only 3:1.

This is not a cosmetic suggestion. Contrast requirements are part of accessibility laws and guidelines that many organizations are legally required to follow, and low-contrast text is one of the most frequently cited accessibility failures on the web. Checking a brand color against white and black before locking it into a design system catches the problem before it ships, rather than after a user complains they cannot read the site.

Where hex and RGB show up outside a browser

Hex codes are everywhere in web development because CSS was designed around them from the start, and they remain the fastest way to paste an exact color between a design tool and a stylesheet. Brand guidelines almost always list a primary hex code for this reason, since a single string is easier to copy correctly than three separate numbers.

RGB shows up more in places that treat color as data rather than text. Canvas and WebGL APIs in JavaScript take numeric channel values directly. Image editing software like Photoshop stores pixel data as RGB internally and only shows you hex when you specifically ask for the web color. Video and broadcast standards work in RGB or its close relatives because the math for blending, dimming, or color-correcting a scene is far simpler with plain numbers than with a hex string you would have to parse first.

Print design is the one place neither hex nor RGB is the right answer. Printers mix ink rather than light, so print workflows use CMYK, cyan, magenta, yellow, and black, instead. A color that looks correct as an RGB or hex value on screen can shift noticeably once it is converted to CMYK for a printed page, which is why designers working across both digital and print media usually keep separate color values for each.

Common mistakes when working with hex and RGB

Forgetting the leading zero on a hex pair is the most frequent manual error, already mentioned above. A close second is confusing RGB with HSL or HSB, which use completely different numbers, hue in degrees, saturation and lightness or brightness as percentages, to represent the same colors. Pasting an HSL value into a field expecting RGB produces a color that has nothing to do with what you intended.

Another common mistake is assuming alpha transparency is part of standard 6-digit hex. It is not. A plain #FF5733 is fully opaque by definition. Transparency only enters the picture with 8-digit hex, RGBA notation, or a separate opacity property in CSS, and mixing these up is a frequent source of "why is my color showing through" bugs in stylesheets.

Frequently asked questions

Double each digit, #FFF expands to #FFFFFF before converting. This shorthand works because each of the three digits represents both the high and low half of that color channel, F becomes FF, 0 becomes 00, and so on.

Each of the three numbers, red, green, and blue, ranges from 0 to 255 and represents how much of that color channel is present. 0 means none of that color, 255 means full intensity, and mixing all three at full intensity produces white.

An 8-character hex code includes an alpha channel for transparency after the standard 6-character color, #FF0000FF is fully opaque red, while #FF000080 is roughly 50% transparent red. Standard 6-digit hex has no transparency information built in.

Neither is strictly better, they represent the same color. Hex is more compact for a fixed color value, while RGB, particularly rgba, is more convenient when you need to control transparency alongside the color itself.

This version converts hex to RGB. Converting the other direction, RGB back to hex, uses the reverse of the same math, each RGB value gets converted to a two-digit hexadecimal number and the three pairs are joined together.