Skip to content
ZeroServer.tools

HEX to RGB

Convert HEX color codes to RGB / RGBA values.

Hex: #00f2feR: 0G: 242B: 254Alpha: 100%
Presets:
HEX Input
RGB
rgb(0, 242, 254)
RGBA
rgba(0, 242, 254, 1)

Reading a HEX Color Code

A HEX code packs red, green, and blue channels into a base-16 string like #RRGGBB. This tool accepts 3-, 4-, 6-, and 8-digit HEX (the 4th/8th pair is the alpha channel) and expands shorthand automatically. It outputs both rgb() and rgba() notation for use in CSS. All conversion is instant and client-side.

Built and maintained by Meet Shah · Last updated

What this tool is used for

  • Converting a hex token into channels for a canvas or an image operation.
  • Producing an rgba value from a hex colour with alpha.
  • Getting channel values to compute a derived colour in code.
  • Converting a hex colour for a tool that needs RGB.
  • Checking two representations describe the same colour.

How it works in practice

A worked example

A stylesheet uses a three-digit hex and a colour with an alpha suffix, and both need to become rgba for a component that takes channels.

Input
#abc
#ff000080
Output
#abc        →  rgb(170, 187, 204)     expanded to #aabbcc
#ff000080   →  rgba(255, 0, 0, 0.5)   alpha 50%

The shorthand is expanded by doubling each digit, not by padding it, which is the step people get wrong from memory: the first form becomes #aabbcc, so the channels are 170, 187 and 204. Padding it instead would give #0a0b0c and a nearly black colour — the same three characters, a completely different result. The second value carries a fourth pair, which is the alpha byte: hex 80 is 128 of 255, so it reports as one half rather than as the exact 0.502 the division produces.

The edge case that catches people

Four-digit shorthand exists too, and it follows the same doubling rule, which makes a pair of very similar strings mean different things. The digits are expanded independently, so a shorthand can only ever express colours whose channels are one of sixteen values repeated — #abc and #aabbcc are the same colour, while #aabbcd cannot be written short at all. If a shorthand and a full form look like they should agree and do not, count the digits before suspecting the tool.

When not to use this tool

Not for a colour that is going to be manipulated rather than merely restated. Lightening, darkening or mixing in these channel values is doing arithmetic in a space that is not perceptually even, which is why a ten percent lighter blue and a ten percent lighter yellow do not look equally lighter — the modern CSS colour functions exist to do that work in a space where the numbers behave. Convert here to move a value between two syntaxes, and reach for those functions when the value has to change.

Frequently Asked Questions

How do I convert by hand?
Each pair of hex digits is one channel: multiply the first digit by 16 and add the second. FF is 15×16 + 15 = 255, and 80 is 8×16 = 128 — which is why #808080 is mid-grey and why "80" appears everywhere as the half-opacity alpha value.
What does the three-digit shorthand expand to?
Each digit doubles: #F60 becomes #FF6600, not #F06000. That is why only colours whose pairs repeat can be shortened at all — #FF6601 has no three-digit form, and a converter that emits six digits is being correct rather than verbose.
When do I need RGB rather than hex?
Whenever a value is computed. `rgb()` lets you interpolate, apply an alpha with `rgb(0 0 0 / 50%)`, or feed channels into a canvas or shader. Hex is a literal; RGB is a number you can do arithmetic on.
Is #RRGGBBAA supported everywhere?
In every current browser, yes — the eight-digit form has been supported since around 2016–2017. Where it still fails is outside the browser: many design tools, email clients and native frameworks accept only six digits and will silently drop the alpha.
Why does the same hex look different on two screens?
Because a hex value names a position in sRGB, and displays vary in how faithfully they render it. An uncalibrated monitor, a wide-gamut screen without colour management, and a phone's vivid mode will each show the same #00F2FE differently.
How does the three-digit shorthand expand?
Each digit is doubled, so `#ABC` becomes `#AABBCC`. That means only 4,096 of the 16.7 million colours are expressible in shorthand — `#AABBCD` has no three-digit form.

Common errors and gotchas

  • Misreading a three-digit shorthand, where each digit doubles rather than being padded with zero.
  • Losing alpha from an eight-digit hex by treating it as six.
  • Assuming the channels are 0-1 floats when they are 0-255 integers, or the reverse.
  • Dropping the leading `#`, which some parsers require and some forbid.
  • Treating an invalid hex as black rather than rejecting it, which hides a typo.

Related Design & CSS tools

Private & free — this tool runs entirely in your browser.

KinstaFast managed hosting — up to $500 + 10% recurring.affiliate