What Is a HEX Color Code?
A HEX color code is a 6-digit hexadecimal number prefixed with #that represents a color in web design — for example, #E8720C is an orange. The six digits are split into three pairs: the first two represent red, the middle two represent green, and the last two represent blue.
Each pair is a base-16 number ranging from 00 (0 in decimal) to FF (255 in decimal), which gives 256 possible values per channel and over 16 million possible colors in total. HEX is the most widely used color format in CSS and HTML — every browser and design tool understands it.
HEX codes can also be written in 3-digit shorthand when both digits of each channel are identical: #ffffff becomes #fff,#000000 becomes #000. All browsers support both forms.
What Is RGB?
RGB stands for Red, Green, Blue — the three primary colors of light. In CSS, it is written as rgb(R, G, B) where each value is an integer from 0 to 255. RGB is the native color model of screens: every pixel on your monitor mixes these three light wavelengths to produce color.
rgb(255, 0, 0) is pure red, rgb(0, 0, 255) is pure blue, rgb(0, 0, 0) is black, and rgb(255, 255, 255) is white. RGBA adds a fourth value for opacity: rgba(232, 114, 12, 0.5) is the same orange at 50% transparency.
HEX to RGB — The Formula and How It Works
Converting HEX to RGB is a base conversion from hexadecimal (base 16) to decimal (base 10). You split the 6-digit HEX code into three 2-digit pairs and convert each one independently.
#E8720C → E8, 72, 0CE8 = 14×16 + 8 = 232, 72 = 7×16 + 2 = 114, 0C = 0×16 + 12 = 12rgb(232, 114, 12)In JavaScript: parseInt("E8", 16) === 232. For any HEX color #RRGGBB: R = parseInt(hex.slice(1,3), 16), G = parseInt(hex.slice(3,5), 16), B = parseInt(hex.slice(5,7), 16).
RGB to HEX — The Formula
To go the other direction — RGB to HEX — you convert each decimal value (0–255) to a 2-digit hexadecimal number and join them with a # prefix.
232/255 = 0.910, 114/255 = 0.447, 12/255 = 0.047Math.round(0.910 × 255) = 232 → 0xE8#E8720C"#" + [232,114,12].map(v => v.toString(16).padStart(2,"0")).join("") === "#e8720c"How to Convert HEX to RGB Online (Step-by-Step)
All Color Formats — What Each One Is and When to Use It
Different workflows require different color formats. Here is every major format, what it looks like, and where it is used:
| Format | Example | Used in | Notes |
|---|---|---|---|
| HEX | #e8720c | CSS, HTML, design tools | 6-digit hexadecimal. Two digits each for red, green, blue. Most common web format. Can be shortened to 3 digits when each pair is identical (#fff = #ffffff). |
| RGB | rgb(232, 114, 12) | CSS, JavaScript, Canvas | Red, Green, Blue values from 0–255. The native format of screens. RGBA adds a fourth value (0–1) for opacity. |
| HSL | hsl(28, 90%, 48%) | CSS, design tools | Hue (0–360°), Saturation (0–100%), Lightness (0–100%). Most human-intuitive — you can adjust brightness independently of hue. |
| HSV / HSB | hsv(28, 95%, 91%) | Photoshop, Figma, Sketch | Hue, Saturation, Value/Brightness. Used in design tool color pickers. Value 100% = the full color; 0% = black. |
| CMYK | cmyk(0%, 51%, 95%, 9%) | Print, InDesign, Illustrator | Cyan, Magenta, Yellow, Key (Black). Subtractive color model for physical printing. Gamut is smaller than RGB. |
| Tailwind CSS | orange-500 | Tailwind CSS framework | Named utility classes. The nearest Tailwind color to any HEX is an approximation — Tailwind has a fixed palette of ~22 colors × 11 shades. |
| iOS / Swift | UIColor(red: 0.910, green: 0.447, blue: 0.047, alpha: 1.0) | Swift, Objective-C, SwiftUI | RGB values expressed as decimals 0.0–1.0. SwiftUI also accepts Color(red:green:blue:) with the same values. |
| Flutter / Dart | Color(0xFFE8720C) | Flutter, Dart | 0xFF prefix for full opacity followed by the 6-digit HEX. Change FF to control alpha (e.g. 0x80 = 50% opacity). |
| Android ARGB | 0xFFE8720C | Android XML, Kotlin, Java | Same as Flutter format. Alpha first (FF = opaque), then RGB. In XML: android:color="#FFE8720C". |
Common Color Reference Table — HEX, RGB, and HSL
A quick reference for 15 frequently used colors in web design — pure colors, common named colors, and Tailwind CSS defaults:
| Color | Swatch | HEX | RGB | HSL |
|---|---|---|---|---|
| White | #FFFFFF | rgb(255, 255, 255) | hsl(0, 0%, 100%) | |
| Black | #000000 | rgb(0, 0, 0) | hsl(0, 0%, 0%) | |
| Red | #FF0000 | rgb(255, 0, 0) | hsl(0, 100%, 50%) | |
| Lime | #00FF00 | rgb(0, 255, 0) | hsl(120, 100%, 50%) | |
| Blue | #0000FF | rgb(0, 0, 255) | hsl(240, 100%, 50%) | |
| Yellow | #FFFF00 | rgb(255, 255, 0) | hsl(60, 100%, 50%) | |
| Tomato | #FF6347 | rgb(255, 99, 71) | hsl(9, 100%, 64%) | |
| Blue-500 (Tailwind) | #3B82F6 | rgb(59, 130, 246) | hsl(217, 91%, 60%) | |
| Green-500 (Tailwind) | #22C55E | rgb(34, 197, 94) | hsl(142, 71%, 45%) | |
| Orange-500 (Tailwind) | #F97316 | rgb(249, 115, 22) | hsl(25, 95%, 53%) | |
| Indigo-500 (Tailwind) | #6366F1 | rgb(99, 102, 241) | hsl(239, 84%, 67%) | |
| Pink-500 (Tailwind) | #EC4899 | rgb(236, 72, 153) | hsl(330, 81%, 60%) | |
| Gray | #808080 | rgb(128, 128, 128) | hsl(0, 0%, 50%) | |
| Orange | #FFA500 | rgb(255, 165, 0) | hsl(39, 100%, 50%) | |
| Purple | #800080 | rgb(128, 0, 128) | hsl(300, 100%, 25%) |
What Is HSL and Why Is It Useful?
HSL (Hue, Saturation, Lightness) is the color format that most closely matches how humans think about color. Instead of specifying red, green, and blue phosphor intensities, you specify:
- Hue (0–360°) — The color itself on the color wheel. 0° = red, 120° = green, 240° = blue.
- Saturation (0–100%) — How vivid or gray the color is. 0% = pure gray, 100% = full color.
- Lightness (0–100%) — How light or dark. 0% = black, 50% = the pure color, 100% = white.
HSL is especially useful in CSS when you want to create variants of a color. To make a color darker, reduce L. To make it lighter, increase L. The hue stays identical. This is why design systems often store brand colors in HSL and generate shade scales by varying L and S.
HEX #E8720C = RGB rgb(232, 114, 12) = HSL hsl(28, 90%, 48%). All three are the same orange — just described differently.
CMYK — When You Need It and When You Don't
CMYK (Cyan, Magenta, Yellow, Black) is a subtractive color model used in physical printing. Unlike RGB which mixes light, CMYK mixes ink — adding more ink makes the color darker. You need CMYK values when:
- Sending files to a professional print shop
- Working in Adobe InDesign or Illustrator for print output
- Creating brand guidelines that specify both digital (RGB) and print (CMYK) values
CMYK is not needed for anything displayed on a screen — websites, apps, social media, presentations. For screen use, HEX or RGB is always correct. Note that RGB colors cannot be perfectly reproduced in CMYK — the CMYK gamut is smaller, so very vivid screen colors may look duller in print.
Color Formats for iOS, Android, and Flutter
When you are handing off a design to a mobile developer, they need platform-specific formats — not CSS HEX codes. Here is what each platform uses and how it maps to HEX:
UIColor(red: 0.910, green: 0.447, blue: 0.047, alpha: 1.0)Color(0xFFE8720C)0xFFE8720C / android:color="#FFE8720C"--brand-primary: #E8720C;The Color Converter tab outputs all of these formats simultaneously — paste in a HEX code and copy iOS, Android, and Flutter values in one step.
Related Tools
After converting your colors, you may want to check whether your text and background color combination meets accessibility standards — the WCAG Contrast Checker (in the Contrast Checker tab) gives you an instant pass/fail for WCAG AA and AAA. If you need a complete color palette for a project, the Palette Generator creates analogous, complementary, and triadic schemes from any base color. For gradient CSS, the Gradient Generator builds linear, radial, and conic gradients with a live preview.
Frequently Asked Questions
How do I convert HEX to RGB?
Split the 6-digit HEX code into three pairs and convert each from base-16 to base-10. Example: #E8720C → E8=232, 72=114, 0C=12 → rgb(232, 114, 12). Use the Color Converter tool to do this instantly for any color.
How do I convert RGB to HEX?
Convert each R, G, B value (0–255) to a 2-digit hexadecimal number and join them with a # prefix. Example: rgb(232, 114, 12) → E8, 72, 0C → #E8720C. In JavaScript: (232).toString(16) === "e8".
What is the difference between HEX and RGB?
HEX (#RRGGBB) and RGB (rgb(R,G,B)) represent the same color in different notation. HEX is more compact; RGB is easier to manipulate numerically. Both are fully supported in CSS — choose whichever your workflow requires.
What is HSL and how is it different from RGB?
HSL (Hue, Saturation, Lightness) describes colors in human-intuitive terms. You can make a color lighter by raising L, or more vivid by raising S, without changing the hue. RGB describes colors as screen phosphor intensities — less intuitive for manual adjustment.
Can HEX codes be 3 digits?
Yes. #abc is shorthand for #aabbcc — it only works when both digits in each channel pair are identical. #fff = #ffffff (white), #000 = #000000 (black), #f00 = #ff0000 (red).
What is CMYK and when do I need it?
CMYK is the color model for print. You need CMYK values when sending files to a print shop or working in InDesign/Illustrator for physical output. For anything displayed on a screen, use RGB or HEX.
How do I use a HEX color in Swift?
Divide each RGB value by 255. Example: #E8720C = rgb(232,114,12) → UIColor(red: 0.910, green: 0.447, blue: 0.047, alpha: 1.0). The Color Converter generates this format automatically.
How do I use a HEX color in Flutter?
Use Color(0xFFRRGGBB) where FF is the alpha (opacity) and RRGGBB is your HEX without the #. Example: #E8720C → Color(0xFFE8720C). Change FF to 80 for 50% opacity.
