HEX to RGB Converter: Convert Color Codes Instantly
Learn how to convert HEX to RGB color codes and RGB to HEX values. Understand the formula, see examples, and use an online converter for instant results.
Color Tools · UtilityHub Blog
Why color codes matter in web development
Every pixel on a website is defined by a color code. Whether you are building a landing page, designing a mobile app, or editing a digital image, you need to translate between HEX and RGB formats — often in seconds.
A hex to rgb converter takes a hex string like #FF5733 and returns rgb(255, 87, 51). An rgb to hex converter does the reverse. Understanding both formats saves time and eliminates guesswork.
What is a HEX color code?
A HEX color code is a 6-digit hexadecimal string preceded by a hash (#). It represents the red, green, and blue channels of a color as two hex digits each.
#RRGGBB
Each pair of hex digits maps to a value between 00 (0 in decimal) and FF (255 in decimal).
| HEX Pair | Decimal Value | Meaning |
|---|---|---|
00 | 0 | No color (black) |
80 | 128 | Medium intensity |
FF | 255 | Full intensity |
Example breakdown
The hex code #FF5733 translates to:
| Component | HEX | Decimal |
|---|---|---|
| Red | FF | 255 |
| Green | 57 | 87 |
| Blue | 33 | 51 |
This produces a vivid orange-red color.
What is an RGB color code?
RGB stands for Red, Green, Blue — the three channels that combine to create any color on a screen. An RGB value uses decimal numbers from 0 to 255 for each channel.
rgb(red, green, blue)
For the same orange-red:
rgb(255, 87, 51)
Both #FF5733 and rgb(255, 87, 51) produce the identical color.
HEX to RGB conversion formula
Converting a HEX code to RGB requires two steps per channel:
- Take the two hex digits for the channel
- Convert them from base-16 to base-10
Manual conversion example
For #1A3F9C:
| Channel | HEX | Calculation | Decimal |
|---|---|---|---|
| Red | 1A | (1 × 16) + 10 = 26 | 26 |
| Green | 3F | (3 × 16) + 15 = 63 | 63 |
| Blue | 9C | (9 × 16) + 12 = 156 | 156 |
Result: rgb(26, 63, 156)
Common hex values to memorize
| HEX | Decimal | Common use |
|---|---|---|
00 | 0 | Black / no color |
33 | 51 | Dark shade |
66 | 102 | Mid-dark |
99 | 153 | Mid-tone |
CC | 204 | Light accent |
FF | 255 | Full intensity |
These six values are the backbone of the CSS "safe" color palette.
RGB to HEX conversion formula
To convert RGB back to HEX:
- Divide each decimal value by 16
- The quotient becomes the first hex digit
- The remainder becomes the second hex digit
Conversion example
For rgb(192, 57, 43):
| Channel | Decimal | ÷ 16 | Quotient | Remainder | HEX |
|---|---|---|---|---|---|
| Red | 192 | 192 ÷ 16 | 12 = C | 0 = 0 | C0 |
| Green | 57 | 57 ÷ 16 | 3 = 3 | 9 = 9 | 39 |
| Blue | 43 | 43 ÷ 16 | 2 = 2 | 11 = B | 2B |
Result: #C0392B — a deep crimson red.
3-digit shorthand HEX codes
Browsers support a shorthand format where each channel is a single hex digit:
| 3-Digit HEX | Expanded 6-Digit HEX | Color |
|---|---|---|
#F00 | #FF0000 | Pure red |
#0F0 | #00FF00 | Pure green |
#00F | #0000FF | Pure blue |
#FFF | #FFFFFF | White |
#000 | #000000 | Black |
#888 | #888888 | Gray |
Each character is simply doubled to produce the full 6-digit equivalent.
Alpha channel (RGBA and HEX8)
Both formats support transparency through an alpha channel:
RGBA
rgba(255, 87, 51, 0.5) /* 50% transparent orange */
8-digit HEX
#FF573380 /* Same 50% transparent orange */
The last two hex digits (80 = 128) represent opacity from 00 (fully transparent) to FF (fully opaque).
Real-world conversion examples
Here is a reference table of 10 common web colors and their conversions:
| Color Name | HEX | RGB | Usage |
|---|---|---|---|
| White | #FFFFFF | rgb(255, 255, 255) | Backgrounds, text |
| Black | #000000 | rgb(0, 0, 0) | Text, borders |
| Navy | #000080 | rgb(0, 0, 128) | Headers, links |
| Crimson | #DC143C | rgb(220, 20, 60) | Alerts, accents |
| Forest Green | #228B22 | rgb(34, 139, 34) | Success states |
| Gold | #FFD700 | rgb(255, 215, 0) | Highlights, badges |
| Coral | #FF7F50 | rgb(255, 127, 80) | CTAs, buttons |
| Slate Gray | #708090 | rgb(112, 128, 144) | Secondary text |
| Tomato | #FF6347 | rgb(255, 99, 71) | Warnings, tags |
| Teal | #008080 | rgb(0, 128, 128) | Brand accents |
Common mistakes when converting color codes
Forgetting the hash symbol
A HEX code always starts with #. Without it, CSS will not recognize the color. Write #FF5733, not FF5733.
Mixing up channel order
RGB is always red, green, blue — not green, red, blue or any other order. Getting the order wrong produces an entirely different color.
Using decimal values above 255
An RGB channel cannot exceed 255. If your conversion produces a value above 255, double-check your math. Values like rgb(300, 0, 0) are invalid and will be ignored by browsers.
Confusing HEX case
HEX codes are case-insensitive. #ff5733 and #FF5733 produce the same color. However, uppercase is conventional.
Where to use each format
| Use Case | Recommended Format | Why |
|---|---|---|
| CSS stylesheets | HEX | Shorter, cleaner syntax |
| JavaScript color manipulation | RGB | Easier to parse and modify numerically |
| Design tools (Figma, Photoshop) | RGB | Individual channel sliders |
| Tailwind CSS | HEX | Most Tailwind color utilities use HEX |
| SVG graphics | HEX or RGB | Both work; HEX is more compact |
| React inline styles | RGB | rgb() works without quotes |
Tips for working with color codes
- Bookmark a converter so you never have to calculate manually during development
- Use uppercase HEX (
#FF5733) for consistency across your codebase - Store colors as HEX in CSS variables and convert to RGB only when you need transparency
- Test contrast ratios after picking colors — use a contrast checker to verify accessibility
- Keep a palette document with all your brand colors in both HEX and RGB formats
How to use the online converter
- Enter a HEX code (with or without the
#prefix) - The RGB equivalent appears instantly — no button click required
- To convert RGB to HEX, enter the red, green, and blue values (each 0-255)
- Copy the result with one click
Both directions work in real time with no page reloads.
What about other color formats?
HEX and RGB are the two most common formats, but they are not the only ones. HSL (Hue, Saturation, Lightness) and CMYK (Cyan, Magenta, Yellow, Black) serve different purposes. HSL is useful for generating color variations programmatically, while CMYK is used in print design. For web and screen work, HEX and RGB remain the standard.
Final thoughts
Converting between HEX and RGB is a foundational skill for any developer or designer. Once you understand the base-16 to base-10 conversion, you can translate any color code manually. For faster workflow, use the online converter to get instant, error-free results every time.