HEX a RGB

El Conversor HEX a RGB transforma códigos de color HEX (#RRGGBB) en sus componentes RGB (red, green, blue) y viceversa. HEX es notación compacta común en CSS; RGB es más legible y soporta transparencia (RGBA). Vista previa en vivo del color.

How to convert HEX to RGB

A HEX color code is a 6-digit hexadecimal number prefixed with #. Each pair of digits represents the red, green, and blue channel intensity from 0 (00) to 255 (FF). To convert, split the code into three pairs and parse each as a base-16 integer: #RRGGBB → R=parseInt(RR,16), G=parseInt(GG,16), B=parseInt(BB,16).

Worked example: var(--color-brand-green) → R = parseInt("1B",16) = 27, G = parseInt("6B",16) = 107, B = parseInt("45",16) = 69 → rgb(27, 107, 69).

Color NameHEXRGB
Red#FF0000rgb(255,0,0)
Green#00FF00rgb(0,255,0)
Blue#0000FFrgb(0,0,255)
White#FFFFFFrgb(255,255,255)
Black#000000rgb(0,0,0)

Cómo usar

  1. 1

    Pega un código HEX (con o sin #) o RGB.

  2. 2

    Ve la conversión automática y la vista previa del color.

  3. 3

    Copia el código en el formato que necesites.

Preguntas frecuentes

Ratings & Reviews

Rate this tool

Sign in to rate and review this tool.

Loading reviews…

What HEX and RGB Are

HEX and RGB are two ways of writing the exact same color. #1B6B45 in HEX is rgb(27, 107, 69) — same red, green, blue values, just expressed as hexadecimal vs decimal. The Microapp HEX to RGB tool converts in either direction instantly: paste a HEX color and get the RGB equivalent, or paste RGB to get HEX.

The conversion happens in your browser, with a live preview swatch so you can confirm the color visually.

How to Use It

  1. Paste your HEX color into the HEX input. Both #1B6B45 and 1B6B45 work.
  2. The RGB output shows the equivalent values: rgb(27, 107, 69).
  3. Or paste RGB values into the RGB input — the HEX output updates.
  4. Click "Copy" next to either format to put it on your clipboard.
Worked example. The HEX #1B6B45 breaks down as:
• R = 1B (hex) = 1×16 + 11 = 27 (decimal)
• G = 6B (hex) = 6×16 + 11 = 107 (decimal)
• B = 45 (hex) = 4×16 + 5 = 69 (decimal)
Result: rgb(27, 107, 69). That's it — pure base-16 to base-10 conversion of three pairs of digits.

Why Both Formats Exist

HEX is compact. Six characters fit in any tweet, Slack message, or design spec without taking much space. The # prefix marks it as a color reliably. Most CSS, HTML, and design files use HEX as the default.

RGB is computational. Code that manipulates colors usually thinks in RGB — adjusting one channel, computing a brightness average, or transitioning between two colors over time. Working with hex strings means parsing them to integers anyway.

RGBA adds transparency. RGB has a fourth-channel sibling, RGBA, where the A is alpha (transparency, 0-1 or 0-255 depending on the syntax). rgba(27, 107, 69, 0.5) is the brand green at 50% opacity. Modern CSS also supports 8-character HEX with alpha (#1B6B4580) but the RGBA syntax is older and more widely supported.

The Math, In One Pass

HEX uses base 16: digits 0-9 plus letters A-F representing values 10-15. Each pair of HEX characters represents one byte (0-255). To convert any HEX pair to decimal, multiply the first character's value by 16 and add the second character's value:

HEXMathDecimal
000×16 + 00 (no color)
FF15×16 + 15255 (full color)
808×16 + 0128 (half)
1B1×16 + 1127
6B6×16 + 11107
454×16 + 569

Reverse for decimal-to-HEX: divide by 16 to get the first hex digit, take the remainder as the second.

Three-Character HEX Shortcuts

CSS allows a 3-character HEX shortcut where each character is doubled. #F00 is shorthand for #FF0000 (pure red); #1B6 is shorthand for #11BB66. The shortcut only works when each pair is identical — colors like #1B6B45 can't be shortened because no pair is identical (1B, 6B, 45 are all different).

Don't try to shorten manually. The Microapp converter outputs full 6-character HEX, which is unambiguous and works everywhere.

Common Pitfalls

Forgetting the #. CSS, JavaScript, and most tools require the # prefix on HEX colors. The Microapp converter strips/adds it automatically.

Confusing RGB syntax. CSS RGB notation is rgb(27, 107, 69) with the values comma-separated and parentheses. Some older code uses rgb(27 107 69) with spaces (modern CSS allows this). Always check what your downstream consumer expects.

RGB values outside 0-255. Each channel only ranges 0-255. Values higher (or negative) get clamped. If your input has rgb(300, 0, 0) the output saturates at #FF0000.

Browser display vs printed color. RGB and HEX describe screen colors (sRGB color space). Printing the same color uses CMYK (cyan, magenta, yellow, black) and the visual result can differ — printers can't reproduce some screen colors exactly. For print, work with your printer's color profile.

Related Tools

For conversion across all four formats (HEX, RGB, HSL, HSV) at once, use the Color Converter. To find the named color closest to a HEX value, see the Color Name Finder. To pick a color visually with a picker, the Hex Color Picker is the right tool.