TR

Home / Guides / How to Convert HEX to RGB Color Codes: Step-by-Step Examples

How to Convert HEX to RGB Color Codes: Step-by-Step Examples

Updated: November 6, 2026 · AracMerkezi

▶ Open HEX ↔ RGB Converter

A HEX color code writes the 0–255 values of the red, green and blue channels side by side in hexadecimal: #RRGGBB and rgb(R, G, B) are two notations for the same color, and each channel is converted with the rule "first character × 16 + second character". This guide shows the conversion step by step with three examples, explains short HEX and 8-digit (transparency) HEX, gives verified commands you can use on the coding side, and works out how to darken and lighten a color. We verified the conversions in the examples by running them in JavaScript and Python.

Hexadecimal in brief

The hexadecimal system uses the digits 0–9 and the letters A–F: A = 10, B = 11, C = 12, D = 13, E = 14, F = 15. A two-digit number is read as first digit × 16 + second digit; the smallest is 00 = 0 and the largest is FF = 15 × 16 + 15 = 255. So a channel takes 256 different values and the three channels together give 256³ = 16,777,216 colors.

Converting HEX to RGB

Split the #RRGGBB code into three two-character groups and convert each group to decimal.

Example 1: #0B7A6B

  1. 0B = 0 × 16 + 11 = 11
  2. 7A = 7 × 16 + 10 = 122
  3. 6B = 6 × 16 + 11 = 107
  4. Result: rgb(11, 122, 107)

Example 2: #FF8800 → FF = 15 × 16 + 15 = 255; 88 = 8 × 16 + 8 = 136; 00 = 0 → rgb(255, 136, 0) (orange).

Converting RGB to HEX

Divide each number by 16; the quotient gives the first digit and the remainder the second.

Example 3: rgb(26, 43, 60)

  1. 26 = 1 × 16 + 10 → 1A
  2. 43 = 2 × 16 + 11 → 2B
  3. 60 = 3 × 16 + 12 → 3C
  4. Result: #1A2B3C

Table of common colors

HEXRGBColor
#FF0000rgb(255, 0, 0)red
#00FF00rgb(0, 255, 0)green
#0000FFrgb(0, 0, 255)blue
#FFFF00rgb(255, 255, 0)yellow
#FFA500rgb(255, 165, 0)orange
#800080rgb(128, 0, 128)purple
#808080rgb(128, 128, 128)gray
#FFFFFFrgb(255, 255, 255)white

In gray tones the three channels are equal: #808080 = rgb(128, 128, 128). The gray line from black to white consists of the values where R = G = B.

Short HEX and 8-digit HEX

Example 4: Darkening and lightening a color

Let #0B7A6B be your main color, rgb(11, 122, 107).

This is a simple approximation compared with HSL, which handles saturation and lightness separately on the color wheel; but it is enough for quickly deriving hover and border shades of a brand color.

Example 5: Reading the channels as percentages

Some tools ask for the channels as 0–100 percentages. For rgb(11, 122, 107): 11 / 255 = 4.3%, 122 / 255 = 47.8%, 107 / 255 = 42.0%. In CSS this can be written as rgb(4.3% 47.8% 42%). That green and blue are high and red is low also explains why #0B7A6B is a dark teal green: the dominant channels set the hue of the color, and their total size sets its brightness.

Where do color codes show up?

The same code circulates in CSS files, design tools, email templates and brand guides. A designer hands over HEX, a charting library wants an RGB array, a mobile app constant expects floating-point values in the 0–1 range. They are all the same three numbers; only the notation changes. Keeping your brand color in a single source (for example a variables file) and deriving the other formats by calculation prevents color drift across platforms.

Conversions verified in code

Common mistakes

Accessibility

It is not enough for a color to look good; there must be enough contrast between text and background. For details see What Is Color Contrast Ratio? WCAG AA and AAA, and for choosing a palette see How to Choose a Color Palette for a Website.

The HEX ↔ RGB Converter accepts formats such as #1A2B3C or 26,43,60. For HSL and CMYK you can use the Color Code Converter, and for contrast the Color Contrast Checker. The JSON Formatter and UUID Generator tools are also available for developers.

Frequently asked questions

Which RGB value does #0B7A6B correspond to?

Since 0B = 11, 7A = 122 and 6B = 107, #0B7A6B equals rgb(11, 122, 107).

How does short HEX notation work?

If both characters of every channel are the same, each character is doubled: #FA0 means #FFAA00 (rgb(255, 170, 0)).

What range do RGB values have?

Each channel is between 0 and 255, which corresponds to 00 through FF in hexadecimal. The three channels together give 16,777,216 colors.

Tools mentioned in this guide

More guides

This article is for general information only and is not legal, financial or medical advice. We are not an official institution.