HEX to RGB Converter
Convert a hexadecimal color code into RGB and RGBA values. Paste any valid HEX, whether it is a short 3-digit form like #f0c, a full 6-digit code, or an 8-digit code with alpha, and get the equivalent rgb() and rgba() strings immediately. The converter validates your input and explains what is wrong instead of silently guessing, so a mistyped code gives a clear message rather than a misleading result. You also see the HSL equivalent and the closest CSS color name for context. Copy any value with a single click. All conversion happens in your browser using shared, tested color math, so results are consistent across every tool on the site.
| Format | Value | Copy |
|---|
How to use the HEX to RGB Converter
- Enter a HEX code. Type or paste a 3, 4, 6, or 8-digit HEX value, with or without the leading #.
- Read the RGB output. See the rgb() and, when alpha is present, rgba() values update instantly.
- Copy the result. Click copy to place the RGB or RGBA string on your clipboard.
Examples
- Six-digit code: #3498db converts to rgb(52, 152, 219).
- Code with alpha: #3498db80 converts to rgba(52, 152, 219, 0.5).
How it works
A HEX code encodes the same red, green, and blue channels as RGB, just in base-16. Each pair of hex digits (00–ff) maps to a 0–255 value. A fourth pair encodes alpha as 0–255, which converts to a 0–1 opacity. Because both notations describe identical channels, HEX to RGB is exact with no rounding loss.
Common use cases
- Getting rgb() values for a canvas, SVG, or WebGL fill
- Adding an alpha channel to an existing HEX color
- Double-checking a HEX code before using it in code
Privacy
All color calculations run in your browser. Nothing you enter is sent to a server. Saved palettes and recent colors are kept only in your browser’s local storage and can be cleared at any time.
Frequently asked questions
What HEX formats are accepted?
3-digit (#f0c), 4-digit with alpha (#f0c8), 6-digit (#ff00cc), and 8-digit with alpha (#ff00cc80), with or without the leading #.
How is alpha handled?
An 8-digit or 4-digit HEX includes alpha, which is converted to a 0–1 value in the rgba() output.
What happens with an invalid code?
You get a clear validation message explaining the problem, such as an invalid length or character, rather than a guessed color.
Is the conversion exact?
Yes. HEX and RGB describe the same channels, so the conversion is exact with no rounding difference.