Hex to RGB Color Converter
Input Parameters
Computed Results
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:
- Select Conversion Mode: Choose whether you want to convert from Hex to RGB or from RGB to Hex.
- 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). - 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.
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:
Inputs & Outputs
| Field | Type | Description |
|---|---|---|
| Conversion Mode | Input | Selects the direction of the conversion (Hex to RGB or RGB to Hex). |
| Hex Color Code | Input | The hexadecimal string representing the color. |
| Red / Green / Blue Channels | Input | The decimal values for each color channel (0–255). |
| Hex Code | Output | The formatted 6-character hexadecimal color string. |
| RGB CSS Value | Output | The standard CSS format, e.g., rgb(255, 215, 0). |
| Normalized Values (0-1) | Output | The channel value scaled to a decimal between 0 and 1. |
| CSS Percentage Format | Output | The 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.