HEX to RGB Converter

Paste a hex colour code and get its rgb() equivalent, with a live swatch, instantly.

Functional RGB Output
rgb(99, 102, 241)
#6366F1

Type or paste a hex colour code and this tool shows you the matching rgb() value as you type, alongside a live swatch of the colour itself. It handles both the full six-digit form (#RRGGBB) and the three-digit shorthand (#RGB), and the leading # is optional. Everything happens in your browser — nothing is sent anywhere.

How the conversion works

A hex code is just three pairs of hexadecimal digits, one each for red, green and blue. The tool reads each pair and converts it from base-16 to a decimal number between 0 and 255 — so #6366F1 becomes rgb(99, 102, 241). If you enter a three-digit shorthand like #F0C, each digit is doubled first (#FF00CC) before converting, which is exactly how browsers interpret it. Anything that isn't a valid 3- or 6-digit hex value is flagged as “Invalid HEX” rather than guessed at.

Why convert hex to RGB

Hex is compact and dominates CSS and design tools, but rgb() is what you need the moment you want to adjust a channel by hand or move to rgba() for transparency — RGB exposes the three values directly. The live preview also runs a quick brightness calculation (a weighted mix of the three channels) to decide whether to label the swatch in dark or light text, so the code stays readable on both pale and deep colours.

Frequently Asked Questions

Does it accept shorthand hex like #F0C?

Yes. A three-digit code is expanded by doubling each digit (#F0C becomes #FF00CC) before conversion, matching how browsers read it. The # is optional either way.

What happens if I type an invalid code?

If the input is not a valid 3- or 6-digit hex value, the result reads "Invalid HEX" and the copy button does nothing, so you never copy a broken value.

Can I get an rgba() value with transparency?

This tool outputs the solid rgb() form. To add transparency, take the three numbers it gives you and wrap them as rgba(r, g, b, alpha) with an alpha between 0 and 1.

Is my colour sent to a server?

No. The conversion and preview run entirely in your browser with JavaScript, so nothing you type leaves your device.