Skip to content

HEX to RGB converter

Convert a hex colour to RGB with a live swatch, alpha support, contrast ratios and every other CSS notation ready to copy.

  • Runs in your browser
  • Nothing you enter is sent
  • Free, no account
HEX to RGB
Type in either box and the other updates immediately. Every other notation is listed underneath with its own copy button.

Three, four, six or eight hex digits, with or without the leading #.

Converted from HEX.

Contrast on white

5.17:1

AA for body text

Contrast on black

4.06:1

AA for large text only

Every notation for the colour you entered, each with a copy button
FormatValueCopy
HEX#2563eb
HEX with alpha#2563ebff
RGBrgb(37, 99, 235)
RGBArgba(37, 99, 235, 1)
RGB (space syntax)rgb(37 99 235)
HSLhsl(221.2, 83.2%, 53.3%)
HSLAhsla(221.2, 83.2%, 53.3%, 1)
HSL (space syntax)hsl(221.2 83.2% 53.3%)
HSV / HSBhsv(221.2, 84.3%, 92.2%)
CMYKcmyk(84.3%, 57.9%, 0%, 7.8%)
Android ARGB#FF2563EB
SwiftUIColor(red: 0.145, green: 0.388, blue: 0.922)
Nearest CSS nameroyalblue (closest match)

CSS custom properties

--color: #2563eb;
--color-rgb: 37 99 235;
--color-hsl: 221.2 83.2% 53.3%;
Try:
Your colour values never leaves this tab — check it yourself—

Starting the network probe…

The counter above wraps fetch, XMLHttpRequest and navigator.sendBeacon in this tab and counts every call. It does not block anything — it just reports.

Two ways to verify independently

  1. Turn off Wi-Fi or enable airplane mode, then use the tool. It keeps working, because the page is already fully loaded.
  2. Open your browser devtools, switch to the Network tab, clear it, and run the tool. No new row appears.

Why this matters

In 2025 researchers found that popular online formatters had retained tens of thousands of user-submitted snippets — JSONFormatter.org and CodeBeautify together exposed roughly 80,000 saved documents, many containing live cloud credentials, private keys and internal database connection strings, because “format this” quietly meant “upload this”. A separate incident exposed roughly 3.5 million user PDFs on a document-conversion service. The only structural fix is not sending the data in the first place: this site is served under a Content-Security-Policy whose connect-src contains no third-party origin, so a request off this device cannot be made even by accident.

The conversion, worked through

A hex colour is three bytes written in base 16, one per channel, in the order red, green, blue. Each pair of digits is a number from 00 to ff, which is 0 to 255 in decimal.

#2563eb
  25 → 2×16 + 5  = 37    (red)
  63 → 6×16 + 3  = 99    (green)
  eb → 14×16 + 11 = 235  (blue)

  rgb(37, 99, 235)

Three-digit shorthand doubles each digit rather than padding it: #2ce is #22ccee, not #0200ce. That is why only colours whose channel pairs each have two identical digits can be written short.

Reference values

HexRGBName or use
#000000rgb(0, 0, 0)Black
#ffffffrgb(255, 255, 255)White
#808080rgb(128, 128, 128)Mid grey — note 128, not 127.5
#ff0000rgb(255, 0, 0)Pure red
#2563ebrgb(37, 99, 235)A typical UI primary blue
#663399rgb(102, 51, 153)rebeccapurple, the only CSS colour added by community request
#0f172argb(15, 23, 42)A dark-mode surface

Eight-digit hex and alpha

A fourth pair encodes opacity: 00 fully transparent, ff fully opaque. #2563eb80 is that blue at roughly 50%. Because alpha is a byte, the common percentages land on values worth remembering: 25% is 40, 50% is 80, 75% is bf, 90% is e6.

Every current browser supports it. rgba() expresses exactly the same thing with a 0–1 alpha and has been supported longer, so use that if you are targeting something ancient.

Why the contrast ratios are on this page

Converting a colour is almost always a step towards using it, and the next question is whether text will be legible on it. WCAG 2.1 asks for 4.5:1 for normal body text and 3:1 for text at 18.66px bold or 24px regular and above. The two figures shown tell you immediately whether white or black text passes.

Two things the number will not tell you: contrast is computed on the composited colour, so a semi-transparent background has to be flattened against what is behind it first; and the ratio says nothing about whether a colour is distinguishable to someone with a colour-vision deficiency — for that, never rely on hue alone to convey meaning.

What this page accepts

More than hex, because people paste what they have: three, four, six or eight hex digits with or without the #; any of the 148 CSS named colours; rgb() and rgba() in both comma and space syntax; hsl(); hsv(); cmyk(); and a bare triple such as 37 99 235. Whatever goes in, every notation comes out in the table, each with its own copy button.

Questions

How does hex map to RGB?

Each pair of hex digits is one channel in base 16. `#2563eb` splits into 25, 63 and eb, which are 37, 99 and 235 in decimal — so `rgb(37, 99, 235)`. Three-digit shorthand doubles each digit: `#2ce` means `#22ccee`.

What does an eight-digit hex code mean?

The last pair is alpha, from 00 (transparent) to ff (opaque). `#2563eb80` is roughly 50% opacity. Every current browser supports it; if you need to target very old ones, use `rgba()` instead.

Why does the page show contrast ratios?

Because the reason for converting a colour is usually that you are about to put text on it. WCAG asks for 4.5:1 for body text and 3:1 for large text, and the two figures shown tell you immediately whether white or black text will pass on this background.

Can I paste a colour name?

Yes. Any of the 148 CSS named colours works — `rebeccapurple`, `tomato`, `cornflowerblue` — as do bare triples like `37 99 235`. The nearest named colour is listed at the bottom of the table for any input.