Calculators.Life Calculator
Math

Hex to RGB Color Converter

Input Parameters

Scenarios
Enter a 3, 6, or 8-character hex color code (with or without #).
Used when converting RGB to Hex
Used when converting RGB to Hex
Used when converting RGB to Hex

Computed Results

RGB CSS Value
rgb(255, 215, 0)
Hex Code#FFD700
Red (0-255)255
Green (0-255)215
Blue (0-255)0
Red Normalized (0-1)1
Green Normalized (0-1)0.843
Blue Normalized (0-1)0
CSS Percentage Formatrgb(100%, 84.31%, 0%)

The Hex to RGB Color Converter translates hexadecimal color codes into Red, Green, and Blue (RGB) values, and vice versa. It helps web developers and designers quickly generate standard CSS RGB strings, normalized decimal values, and percentage-based color formats for digital projects.

How to Use the Converter

Follow these steps to convert colors between Hex and RGB formats:

  1. Select Conversion Mode: Choose whether you want to convert from Hex to RGB or from RGB to Hex.
  2. Enter Your Values: If converting from Hex, enter a 3 or 6-character hex code (e.g., FFD700). If converting from RGB, input the Red, Green, and Blue channel values (ranging from 0 to 255).
  3. Review the Results: The calculator instantly provides the corresponding Hex code, the standard RGB CSS value, normalized values (0 to 1), and the CSS percentage format.

Formula & Conversion Logic

Color conversion relies on translating numbers between base-16 (hexadecimal) and base-10 (decimal) systems.

Hex to RGB

A standard 6-character hex code represents three color channels: Red (first two characters), Green (middle two), and Blue (last two). To find the RGB values, convert each 2-character hexadecimal pair into a decimal number.

Decimal Value = (First Hex Digit × 16) + (Second Hex Digit × 1)

If a 3-character shorthand hex code is used (like #F00), the calculator duplicates each character to form a 6-character code (#FF0000) before converting.

RGB to Hex

To convert RGB to Hex, divide each decimal color value (0–255) by 16. The quotient becomes the first hex digit, and the remainder becomes the second hex digit. The three resulting pairs are combined to form the final hex code.

Normalization and Percentages

The calculator also provides normalized values and percentages by comparing the channel value against the maximum possible value of 255:

Normalized Value = Channel Value ÷ 255
Percentage = (Channel Value ÷ 255) × 100

Inputs & Outputs

FieldTypeDescription
Conversion ModeInputSelects the direction of the conversion (Hex to RGB or RGB to Hex).
Hex Color CodeInputThe hexadecimal string representing the color.
Red / Green / Blue ChannelsInputThe decimal values for each color channel (0–255).
Hex CodeOutputThe formatted 6-character hexadecimal color string.
RGB CSS ValueOutputThe standard CSS format, e.g., rgb(255, 215, 0).
Normalized Values (0-1)OutputThe channel value scaled to a decimal between 0 and 1.
CSS Percentage FormatOutputThe RGB value expressed as percentages for CSS use.

Verified Scenario Walkthroughs

Here are examples of how different color values are converted:

Convert Pure Black to RGB

Entering the hex code 000000 results in an RGB CSS value of rgb(0, 0, 0). Because all channels are at their absolute minimum, the normalized values and CSS percentages are all exactly 0.

Convert Standard Blue Hex to RGB

Converting the hex code 4A90E2 yields an RGB CSS value of rgb(74, 144, 226). The normalized values are 0.29 for Red, 0.565 for Green, and 0.886 for Blue. The CSS percentage format is rgb(29.02%, 56.47%, 88.63%).

Convert Mid-Range RGB Values to Hex

If you input an RGB value of 128 for Red, 128 for Green, and 128 for Blue, the resulting Hex code is #808080. This represents a perfect mid-tone gray, with normalized values of 0.502 across all channels.

Convert Maximum RGB Values to Hex

Entering the maximum RGB values of 255 for Red, 255 for Green, and 255 for Blue generates the Hex code #FFFFFF (pure white). The normalized values are 1 for all channels, and the CSS percentage format is rgb(100%, 100%, 100%).

Practical Use Cases

This converter is primarily used in digital design and web development. When styling websites, developers often receive brand guidelines in Hex format but may need RGB values to apply CSS opacity (using rgba()). Conversely, a designer might sample a color in a photo editing tool that provides RGB values, which then need to be converted to Hex for use in a stylesheet. The normalized and percentage outputs are particularly useful for modern CSS frameworks and graphics programming environments that require 0-to-1 or percentage-based color definitions.

Frequently Asked Questions

How do 3-character hex codes work?

A 3-character hex code is a shorthand format used in CSS. To convert it to a standard 6-character code, each character is duplicated. For example, the hex code #F00 becomes #FF0000.

What are normalized RGB values?

Normalized RGB values represent the intensity of each color channel on a scale from 0 to 1, rather than 0 to 255. This is calculated by dividing the standard channel value by 255. Normalized values are often used in 3D rendering and graphics programming.

Author portrait
About the Author
Arnab Biswas

Calculator developer and SEO strategist who builds practical online calculators and tests calculation logic, input handling, and expected results using real-world scenarios.