Hex to RGB Converter
Convert 3, 6, or 8-digit hexadecimal color codes to CSS RGB / RGBA channels with live preview, math breakdown, and JavaScript snippet.
How to Use This Tool
- Enter or paste your HEX value or choose one of the curated preset swatches.
- Copy the formatted RGB value directly, or inspect the secondary HEX, RGB, HSL, and OKLCH chips below.
- Click into Tailwind Scale Generator or Contrast Checker to validate accessibility on the converted shade.
Key Features
- Bidirectional parsing supporting CSS Color Level 4 syntax cleanly
- A 6-digit hex triplet #RRGGBB splits into three base-16 integers (00–FF). Multiply the first digit by 16 and add the second digit to obtain Red, Green, and Blue values from 0 to 255.
- Instant clipboard feedback with live OKLCH and Display-P3 gamut safety
- Zero server round-trips—every calculation executes immediately in browser memory
How Hex converts to RGB bytes
A 6-digit hex triplet #RRGGBB splits into three base-16 integers (00–FF). Multiply the first digit by 16 and add the second digit to obtain Red, Green, and Blue values from 0 to 255.
Reference Snippet (JavaScript)
function hexToRgb(hex) {
const clean = hex.replace('#', '');
const num = parseInt(clean, 16);
return {
r: (num >> 16) & 255,
g: (num >> 8) & 255,
b: num & 255,
};
}Frequently Asked Questions
Yes. Each digit doubles (#ff5500), scaling cleanly across 0–255 channels.
ColorToolkits provides both modern space-separated rgb(37 99 235) and legacy comma syntax.
More Color Tools
View all tools →Color Converter
Convert single or bulk colors across HEX, RGB, HSL, OKLCH, P3, CMYK, and mobile formats.
Color Picker & Eyedropper
Pick exact colors in HEX, RGB, HSL, or OKLCH and sample pixels directly from your screen.
Tailwind Color Scale
Turn any brand color into a balanced 50–950 Tailwind scale with live contrast checks.
Contrast Checker
Check text and UI contrast against WCAG AA/AAA and APCA standards, with 1-click fixes.