Convert HEX color values to RGB format
Convert HEX (Hexadecimal) color codes to RGB (Red, Green, Blue) format instantly with our free online HEX to RGB converter. This tool helps web developers, designers, and digital creators transform hexadecimal color values into RGB format for use in various design and programming applications. Simply paste your HEX code or use the color picker and get the corresponding RGB values in real-time.
HEX to RGB conversion transforms hexadecimal color codes (#RRGGBB) to RGB format (red, green, blue values from 0-255). This is essential when you need to manipulate individual color channels, calculate color differences, or work with graphics libraries that expect RGB values.
The converter parses the hex string, extracts pairs of characters for each channel (RR, GG, BB), and converts each pair from base-16 to base-10. The # prefix is removed first. Short format (#RGB) is expanded to full format (#RRGGBB) by doubling each character.
HEX colors use base-16 digits (0-9, A-F). Each pair represents a value from 00 (0) to FF (255). The conversion uses parseInt(hex, 16). Three-digit shorthand (#RGB) represents #RRGGBB where each digit is doubled: #F00 = #FF0000. Eight-digit HEX (#RRGGBBAA) includes alpha channel.
Convert to RGB to adjust brightness, saturation, or individual channels.
#3498DB → rgb(52, 152, 219), then lighten by increasing each valueMany graphics libraries and APIs expect RGB arrays or objects.
Calculate contrast ratios, color distances, or interpolate between colors.
Generate color scales and gradients programmatically.
function hexToRgb(hex) {
// Remove # and handle shorthand
hex = hex.replace('#', '');
if (hex.length === 3) {
hex = hex.split('').map(c => c + c).join('');
}
const r = parseInt(hex.substring(0, 2), 16);
const g = parseInt(hex.substring(2, 4), 16);
const b = parseInt(hex.substring(4, 6), 16);
return { r, g, b };
}
// Usage
hexToRgb('#3498DB'); // { r: 52, g: 152, b: 219 }
hexToRgb('#F00'); // { r: 255, g: 0, b: 0 }
// As CSS string
const { r, g, b } = hexToRgb('#3498DB');
const cssRgb = `rgb(${r}, ${g}, ${b})`;parseInt with base 16 converts hex strings to numbers. Handle both 3 and 6 digit formats.
def hex_to_rgb(hex_color):
"""Convert hex color to RGB tuple."""
hex_color = hex_color.lstrip('#')
# Handle shorthand (#RGB)
if len(hex_color) == 3:
hex_color = ''.join(c * 2 for c in hex_color)
return tuple(int(hex_color[i:i+2], 16) for i in (0, 2, 4))
# Usage
hex_to_rgb('#3498DB') # (52, 152, 219)
hex_to_rgb('#F00') # (255, 0, 0)
# With Pillow (PIL)
from PIL import ImageColor
rgb = ImageColor.getrgb('#3498DB') # (52, 152, 219)int(hex, 16) parses hex strings. Pillow's ImageColor handles various color formats.
Use HEX to RGB when you need to manipulate colors programmatically: adjusting brightness, calculating contrast ratios, generating color scales, or working with graphics APIs that expect RGB values.
Expand each digit by doubling it: #RGB becomes #RRGGBB. So #F00 is #FF0000, #369 is #336699. Check string length and expand if needed before converting.
Convert cmyk to rgb instantly. Perfect for web designers, developers, and digital artists. Supports batch conversion, copy to clipboard, and real-time preview.
Convert hsv to rgb instantly. Perfect for web designers, developers, and digital artists. Supports batch conversion, copy to clipboard, and real-time preview.
Convert random color instantly. Perfect for web designers, developers, and digital artists. Supports batch conversion, copy to clipboard, and real-time preview.
Convert rgb to cmyk instantly. Perfect for web designers, developers, and digital artists. Supports batch conversion, copy to clipboard, and real-time preview.
Convert rgb to hex instantly. Perfect for web designers, developers, and digital artists. Supports batch conversion, copy to clipboard, and real-time preview.
Convert rgb to hsv instantly. Perfect for web designers, developers, and digital artists. Supports batch conversion, copy to clipboard, and real-time preview.