Skip to content

RGB to HEX converter

Convert rgb() or rgba() values to a hex colour code, with alpha folded into an 8-digit hex and every other notation ready to copy.

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

Three channels, 0–255 each. Commas or spaces both work.

Converted from RGB.

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.

Converting a channel by hand

Each channel is one byte, so the conversion is integer division by 16 for the first digit and the remainder for the second, with 10 to 15 written as a to f.

rgb(37, 99, 235)
  37  → 37 ÷ 16 = 2 remainder 5   → 25
  99  → 99 ÷ 16 = 6 remainder 3   → 63
  235 → 235 ÷ 16 = 14 remainder 11 → eb

  #2563eb

The useful mental anchors: 0 is 00, 128 is 80, 255 is ff, and any multiple of 17 gives a repeated digit (17 → 11, 34 → 22, …, 255 → ff), which is exactly the set of channels expressible in shorthand.

Input formats that work here

  • rgb(37, 99, 235) — the classic comma syntax.
  • rgb(37 99 235) — the modern space syntax, with / 50% for alpha.
  • rgba(37, 99, 235, 0.5) — alpha as 0 to 1.
  • rgb(15%, 39%, 92%) — percentage channels, scaled by 2.55.
  • 37, 99, 235 or 37 99 235 — a bare triple, which is what you get when copying out of a design tool.

Values outside 0–255 are clamped rather than rejected, which is also what a browser does.

Why hex is still the default in design tools

Functionally, hex and rgb() are identical — the browser resolves both to the same three bytes. Hex persists for practical reasons: it is six characters instead of eighteen, it double-clicks as a single token in most editors, it pastes cleanly into a spreadsheet cell or a Slack message, and every design tool’s colour field accepts it. Handing a developer #2563eb is unambiguous in a way that “the blue” is not.

Precision, and where it goes

Whole-number channels convert exactly: 0–255 maps one-to-one onto 00–ff, so hex → rgb → hex always returns the byte you started with. Two inputs do round. A percentage channel is multiplied by 2.55 and rounded, so 39% becomes 99 rather than 99.45. An alpha of 0.5 becomes 80, which is 128/255 or 50.2%. Neither difference is visible, but it explains why an alpha you round-trip may come back as 0.502.

Shorthand, and when not to use it

Three-digit hex only exists when every channel has two identical digits. It saves three characters and costs a little clarity: #24c is harder to compare against #2563eb at a glance than #2244cc is. In a design-token file, prefer the full form so every value lines up in the same column.

Questions

What input formats are accepted?

`rgb(37, 99, 235)`, the modern space syntax `rgb(37 99 235 / 50%)`, percentages, `rgba()` with a 0–1 alpha, and a bare triple such as `37, 99, 235`. Anything out of range is clamped to 0–255 rather than rejected.

Why do designers still use hex?

Habit and compactness. Six characters carry the same information as `rgb(37, 99, 235)` and paste more cleanly into a spreadsheet, a Figma field or a Slack message. Functionally the two are identical to a browser.

Does converting lose precision?

Not for whole-number channels — 0–255 maps exactly onto 00–ff. Percentages and alpha do round: an alpha of 0.5 becomes 80 in hex, which is 128/255, or 50.2%. The difference is invisible.

Where does the shorthand form come from?

Three-digit hex is only possible when both digits of every channel match — `#2244cc` can be written `#24c`, but `#2563eb` cannot. The full form is always shown; shorthand is only ever a convenience.