Skip to content
100% in your browser. Nothing you paste is uploaded — all processing runs locally. Read more →

Hex → RGB

Paste a hex color, get RGB instantly. #2563ebrgb(37, 99, 235). The full converter at the bottom also gives you HSL and OKLCH.

#2563eb
Presets
🔒 100% client-side · uses browser's native color parsing · no upload

The conversion in one paragraph

Hex colors pack three 8-bit RGB channels into a 6-character hexadecimal string. Each pair of hex digits represents one byte (0–255):

#2563eb
 │└┴ blue:  0xeb = 235
 │└── green: 0x63 = 99
 └─── red:   0x25 = 37
        rgb(37, 99, 235)

The 3-digit shorthand

CSS allows a 3-digit form where each digit is doubled:

#27e  →  #2277ee  →  rgb(34, 119, 238)
#fff  →  #ffffff  →  rgb(255, 255, 255)
#000  →  #000000  →  rgb(0, 0, 0)

Useful when the value happens to repeat each digit; otherwise stick with the full 6-digit form.

Common conversions

HexRGBName
#000000rgb(0, 0, 0)Black
#ffffffrgb(255, 255, 255)White
#ff0000rgb(255, 0, 0)Red
#00ff00rgb(0, 255, 0)Green (lime in CSS)
#0000ffrgb(0, 0, 255)Blue
#2563ebrgb(37, 99, 235)Tailwind blue-600
#7c3aedrgb(124, 58, 237)Tailwind violet-600
#10b981rgb(16, 185, 129)Tailwind emerald-500
#f59e0brgb(245, 158, 11)Tailwind amber-500
#ef4444rgb(239, 68, 68)Tailwind red-500

In code

// JavaScript / Node — most concise
const rgb = (h) => h.match(/[0-9a-f]{2}/gi).map(c => parseInt(c, 16));
rgb("2563eb");  // [37, 99, 235]

// JavaScript — with shorthand support
function hexToRgb(hex) {
  let h = hex.replace(/^#|^0x/i, "");
  if (h.length === 3) h = h.split("").map(c => c + c).join("");
  if (h.length !== 6) throw new Error("Invalid hex");
  return [
    parseInt(h.slice(0,2), 16),
    parseInt(h.slice(2,4), 16),
    parseInt(h.slice(4,6), 16),
  ];
}

// Python
def hex_to_rgb(s):
    s = s.lstrip("#")
    if len(s) == 3:
        s = "".join(c + c for c in s)
    return tuple(int(s[i:i+2], 16) for i in (0, 2, 4))

// Bash
hex="2563eb"
printf "%d, %d, %d\n" 0x${hex:0:2} 0x${hex:2:2} 0x${hex:4:2}

// Go
import "strconv"
r, _ := strconv.ParseInt(hex[:2], 16, 32)

Common pitfalls

Try the reverse direction

FAQ

What's the formula?

Each pair of hex digits is one byte (0–255). #RRGGBBrgb(R, G, B) where each component is parsed from 2 hex digits. #fff is shorthand for #ffffff — repeat each digit.

Does it handle the 3-digit shorthand?

Yes. #27e expands to #2277ee = rgb(34, 119, 238). The expansion is per-channel: each single hex digit is doubled.

Can I paste with or without #?

Both. 2563eb, #2563eb, and 0x2563eb all work — the parser strips common prefixes.