Skip to content

Hex to RGB Converter

Convert any hex color code to RGB in your browser — 3-digit, 6-digit, and 8-digit alpha hex all supported. Free, instant, no signup, your colors never leave the page.

No Tracking Runs in Browser Free
All color conversion happens locally in your browser. No data is sent to any server.
Gamut: sRGB Display P3 Rec2020
Contrast vs:
AA AA-Lg AAA AAA-Lg · APCA Lc
Color blindness simulation (8 types)
Protanopia (red-blind)
Deuteranopia (green-blind)
Tritanopia (blue-blind)
Achromatopsia (total)
Protanomaly (red-weak)
Deuteranomaly (green-weak)
Tritanomaly (blue-weak)
Achromatomaly (partial)
Tints / Shades / Tones / Harmonies

Tints

Shades

Tones

Harmonies

Copy as code
Common colors reference
Reviewed for CSS Color 4 conformance, 3/4/6/8-digit hex shape support, alpha-pair decoding correctness, and round-trip bit-exactness between HEX and RGB across the 0-255 range. — Go Tools Engineering Team · May 27, 2026

What Is a Hex to RGB Converter?

A hex to RGB converter is a small utility that turns a hex color code (`#FF5733`) into the three integer channel values it represents (`rgb(255 87 51)`). Hex and RGB are the two formats every web stylesheet, design tool, and image-pixel pipeline has been built around since the late 1990s, and the conversion between them is the single most common operation in color tooling. Hex is the terse copy-paste format that Figma, Sketch, Photoshop, and every brand-guidelines PDF export by default — a 6-character base-16 string that fits in a CSS custom property comfortably and reads at a glance once your eyes learn the patterns. RGB is the channel-addressed format that hardware APIs, canvas drawing calls, image-buffer manipulation, OpenGL color attributes, and most graphics SDKs expect — three separate 0-255 integers (or 0-1 normalized floats) that map directly to the red, green, and blue subpixels of an LCD or the phosphors of a CRT. Converting between them is mechanical: split the hex into three 2-digit pairs and read each pair as a base-16 number. This tool runs that conversion live as you type, with no "Convert" button to click, and surfaces every other common color format (HSL, OKLCH, OKLAB, HSV, HWB, CMYK, plus the 148 CSS named colors) alongside the RGB output for free.

**The RGB format itself deserves a closer look.** Standard 24-bit sRGB encodes each channel as an 8-bit unsigned integer from 0 to 255 — 256 values per channel, 16,777,216 colors total (256³). The reference standard is IEC 61966-2-1, the 1996 sRGB specification anchored to the CRT phosphor primaries that dominated displays at the time. CSS exposes RGB through the `rgb()` function in three syntactic flavors. The original CSS 1 form uses comma separators: `rgb(255, 87, 51)`. CSS Color 4 (W3C Candidate Recommendation since 2022) added a modern space-separated form: `rgb(255 87 51)`, with an optional alpha channel after a slash: `rgb(255 87 51 / 0.5)`. Both forms are interchangeable and ship in every evergreen browser. RGB also accepts percentage channels: `rgb(100% 33% 20%)` is equivalent to `rgb(255 87 51)`, sometimes preferred in hand-written stylesheets for readability. Alpha specifically has a separate `rgba()` function for legacy support — `rgba(255, 87, 51, 0.5)` is the canonical form that works everywhere down to IE 9. CSS Color 4 also added a `color(srgb 1 0.341 0.2)` syntax for explicit sRGB addressing, and parallel `color(display-p3 ...)` and `color(rec2020 ...)` functions for wide-gamut values that hex can't encode.

The conversion math goes both directions cleanly. **HEX to RGB**: parse the 6-digit hex `#RRGGBB` as three 2-digit base-16 numbers via `parseInt(hex.slice(1, 3), 16)`, `parseInt(hex.slice(3, 5), 16)`, `parseInt(hex.slice(5, 7), 16)`. For 3-digit shorthand `#RGB`, expand each digit by duplicating it (`#F73` → `#FF7733`) before parsing — this is *not* a left-pad. For 8-digit alpha `#RRGGBBAA`, parse the trailing pair the same way and divide by 255 to get the 0-1 alpha float. For 4-digit alpha shorthand `#RGBA`, expand each digit first (`#F738` → `#FF773388`). **RGB to HEX** is the inverse: for each channel, call `value.toString(16).padStart(2, '0')` to get the 2-digit hex pair (the `padStart` matters — without it, channel value 5 would serialize as `'5'` instead of `'05'`, producing invalid hex), then concatenate. Both directions are bit-exact in either direction: 16² = 256, exactly matching the 0-255 byte range each channel occupies, so a HEX → RGB → HEX round-trip produces the original input verbatim with no float drift.

**Why hex versus RGB?** Hex is shorter, design-tool-native, and the format your eye learns over time — most front-end developers can identify `#3b82f6` as Tailwind blue-500 at a glance. RGB is explicit-channel-addressing, easier to compute against in JavaScript, and the only of the two that accepts alpha and percentages cleanly. The two formats coexist because they solve different problems. Web stylesheets and brand guidelines lean hex because copy-paste cost dominates. Canvas drawing calls, image processing, hardware-LED APIs, and any code that does per-channel arithmetic lean RGB because indexing into a tuple beats slicing a string. The shift between them happens dozens of times in a typical web project — paste a hex from Figma, convert to RGB integers for a `ctx.fillStyle = ...` call, convert back to hex for a CSS variable definition.

This tool's HEX → RGB workflow is one direction of a 5-spoke family that all share the same underlying unified color converter. The dedicated unified color converter is the hub — it shows all 9 formats simultaneously editable and is the right tool when your workflow needs more than just hex and RGB. The single-direction spokes target specific Google search intents: the reverse RGB to hex converter for the inverse direction, the hex to HSL converter for the legacy designer-cognitive space, the hex to OKLCH converter for modern perceptually-uniform design systems (Tailwind v4 and shadcn both default to OKLCH now), and the hex to CMYK converter for print-prep approximations. All five spokes and the hub share the same parsing engine and the same conversion math, so the results are guaranteed identical across the family. Every conversion runs locally in your browser — your hex codes are never uploaded, never logged, and zero network requests fire as you type. Verify in DevTools.

// Parse any hex shape (3/4/6/8-digit) into an RGB tuple [r, g, b, a]
// All channels in 0-255 range; alpha in 0-1.
function parseHex(input) {
  let h = input.trim().replace(/^#/, '');
  // Expand 3-digit and 4-digit shorthand by duplicating each digit
  if (h.length === 3 || h.length === 4) {
    h = h.split('').map(c => c + c).join('');
  }
  if (!/^[0-9a-fA-F]+$/.test(h) || (h.length !== 6 && h.length !== 8)) {
    throw new Error(`Invalid hex: ${input}`);
  }
  const r = parseInt(h.slice(0, 2), 16);
  const g = parseInt(h.slice(2, 4), 16);
  const b = parseInt(h.slice(4, 6), 16);
  const a = h.length === 8 ? parseInt(h.slice(6, 8), 16) / 255 : 1;
  return [r, g, b, a];
}

console.log(parseHex('#FF5733'));   // [255, 87, 51, 1]
console.log(parseHex('#F73'));       // [255, 119, 51, 1]
console.log(parseHex('#FF573380'));  // [255, 87, 51, 0.5019607843137255]

Key Features

All Five Hex Shapes Parsed Identically

3-digit `#F73`, 4-digit alpha `#F738`, 6-digit `#FF5733`, 8-digit alpha `#FF5733CC`, plus the no-`#` variant for each (`F73`, `FF5733`, etc.). The parser normalizes all of them into the same internal RGB tuple before display, so you can paste whichever shape your source uses without manually expanding shorthand first. Capitalization is also normalized — `#ff5733` and `#FF5733` produce identical output.

RGB Output in Modern Space-Separated Syntax

The RGB field surfaces the value in CSS Color 4's modern form: `rgb(255 87 51)` for opaque colors, `rgb(255 87 51 / 0.5)` for alpha-bearing ones. Both shapes work in every evergreen browser (Chrome 65+, Safari 13+, Firefox 52+). The legacy comma form `rgb(255, 87, 51)` is one mechanical replace away if your target needs it; the modern syntax is preferred in new code because it aligns with CSS Color 4's other functional syntaxes.

Bit-Exact, No Float Drift

HEX → RGB is integer-to-integer math: `parseInt(hex, 16)` returns an exact 0-255 value with zero float involvement. The reverse direction (`.toString(16).padStart(2, '0')`) is equally exact. A round-trip HEX → RGB → HEX → RGB → HEX produces the original input verbatim, indefinitely. The OKLCH internal source-of-truth means even the longer chain HEX → RGB → HSL → OKLAB → HEX stays bit-stable, which legacy converters routing through HSL don't guarantee.

Alpha Channel Decoded Cleanly

8-digit and 4-digit hex with alpha (`#RRGGBBAA` and `#RGBA`) are parsed correctly. The trailing pair maps to a 0-1 alpha float: `00` → 0, `80` → 0.502, `FF` → 1. The output uses CSS Color 4's slash syntax (`rgb(255 87 51 / 0.5)`) by default; the legacy `rgba(255, 87, 51, 0.5)` form is one replace away. Useful for design-token migration where alpha values may have been buried in 8-digit hex codes.

Eight Other Formats Visible Simultaneously

The same hex you paste also drives HSL, HSV, HWB, OKLCH, OKLAB, CMYK, and the closest CSS named color — all visible at a glance on the same page. You're never locked into hex → RGB only. If a teammate needs the OKLCH triple for a Tailwind v4 token, the closest named color for documentation prose, or the CMYK approximation for a print quote, the values are already there with their own Copy buttons.

WCAG + APCA Contrast Built In

Pass a hex through and the contrast row immediately scores it against both white and black using WCAG 2.1 (regulatory floor: 4.5:1 for body text, 7:1 for AAA) and APCA Lc (proposed WCAG 3 successor: target `|Lc| ≥ 75` for body text). Useful when you've just converted a brand hex to RGB and want to verify it's actually readable as a body-text color before shipping it.

Copy as CSS / Tailwind v4 / SwiftUI / Compose / Flutter

Below the picker, the Copy as code section turns the current color into ready-to-paste snippets for five platforms: CSS custom property (`--color-brand: rgb(255 87 51)`), Tailwind v4 `@theme` token, SwiftUI `Color(red:green:blue:)` literal, Jetpack Compose `Color(0xFFFF5733)` constant, Flutter `Color(0xFFFF5733)`. The exact syntax each platform expects, ready to drop into an iOS asset catalog, Android theme file, or Flutter `ThemeData`.

100% In-Browser — No Upload, No Tracking

All hex parsing, RGB conversion, contrast scoring, and palette generation runs locally in your browser. Your hex codes are never transmitted, never logged on any server, never analyzed. Zero network requests as you type — verify in DevTools. Safe for unannounced brand palettes, internal design tokens, draft mockups under NDA, and any other confidential color work.

Shareable URL Hash for the Exact Color

The current color encodes into the URL hash as `#hex=ff5733` automatically on every change. Copy the URL, paste into a Slack thread or a GitHub issue, and anyone who opens it lands on the same hex with the same RGB result. The hash lives only in your address bar and is never transmitted to the server (browsers don't include URL fragments in HTTP requests), so even sharing the link doesn't leak the color to any third party.

Hex to RGB Converter Alternatives

RapidTables Hex to RGB

browser tool

The default Google result for "hex to rgb" — a single-direction form with hex in, RGB out, no other formats visible. Useful for one-off lookups when arriving from search. Lacks OKLCH, contrast checking, gamut detection, alpha handling, and the multi-format simultaneous view. This tool wins on every axis except the bare-bones single-conversion case.

ColorHexa

browser tool

Long-running per-color SEO pages with deep metadata: conversions, palettes, harmonies, gradients for any hex you query. UI is dated (early-2010s), no OKLCH support, no APCA contrast, no wide-gamut handling. Strong for SEO discovery of a specific hex via Google; weaker for active conversion workflows where typing into a unified-field UX is faster.

W3Schools Hex Calculator

browser tool

Beginner-friendly HEX/RGB/HSL toggle on a teaching-focused page, ubiquitous in search results. No OKLCH, no alpha handling beyond rgba, no advanced features. Useful as a reference next to W3Schools' explainer content. This tool wins on every other axis: more formats, perceptual math, gamut + contrast + CVD features, modern code export for Tailwind v4 / SwiftUI / Compose / Flutter.

Browser DevTools Color Picker

built-in browser feature

Chrome, Firefox, and Safari DevTools all ship a color picker that converts hex to RGB inline when you click a color swatch in the CSS pane. Free, no install, always available. Lacks OKLCH, lacks shareable URLs, lacks code-export for non-web platforms (SwiftUI, Compose). Reach for DevTools when you're already debugging CSS; reach for this tool when you need cross-platform output.

macOS Digital Color Meter

native macOS app

Bundled with every Mac since OS X — hover over any pixel and read the RGB / hex / linear values. Excellent for sampling pixel colors from any app on screen. Doesn't convert pasted hex values; it's a screen-sampler, not a converter. Use the EyeDropper button in this tool's picker (Chromium browsers only) for the same screen-sampling capability inside the browser.

ConvertingColors

browser tool

Per-color SEO pages covering many spaces (HEX, RGB, HSL, HSV, CMYK, XYZ, CIELAB). Lacks modern OKLCH support and the unified-field editing UX. Auto-generated content pages feel content-farm-ish but the conversion data is correct. Good for spelunking individual color metadata via Google; this tool is faster for active workflows.

Hex to RGB Examples

Paste a hex from a screenshot → RGB tuple

#FF5733

RGB output: `rgb(255 87 51)`. The classic use case — a designer dropped a brand color into Figma, you screenshotted it, an eyedropper gave you the hex, and now you need the channel integers for a canvas drawing call, a hardware LED strip, or pixel-math against an image buffer. The CSS Color 4 space-separated syntax shown is the modern form; the legacy comma form `rgb(255, 87, 51)` is identical in meaning and supported in every browser since IE 3.

Convert Tailwind brand hex to RGB for Photoshop

#3b82f6

RGB output: `rgb(59 130 246)`. Adobe's Color picker (in Photoshop, Illustrator, and InDesign) accepts RGB integers in the 0-255 range as its native input — paste 59 / 130 / 246 into the three channel boxes and you've matched Tailwind's `blue-500` exactly. Useful when a designer needs to mock up a web color in a print-aware layout app, or when you're sampling brand colors into a swatch library for image edits.

8-digit hex with alpha → rgba

#FF573380

RGB output: `rgb(255 87 51 / 0.5)`. The last pair (`80`) decodes as `128/255 ≈ 0.502`, surfaced as the alpha channel via CSS Color 4's slash syntax. The equivalent legacy form is `rgba(255, 87, 51, 0.5)`, which is still supported everywhere and what older preprocessors expect. 8-digit hex shipped natively in all evergreen browsers in 2018; before that, alpha had to be expressed via the `rgba()` function.

Short 3-digit hex expansion

#F73

RGB output: `rgb(255 119 51)`. The CSS spec defines 3-digit hex as a shorthand where each digit is duplicated to form the 6-digit equivalent: `#F73` expands to `#FF7733`, so R = `FF` = 255, G = `77` = 119, B = `33` = 51. This is *not* a left-pad — `#F73` is **not** `#000F73`. Many beginners get this wrong; the tool's expansion behavior makes the rule visible at a glance.

Common Hex → RGB Conversions

Reference table of the 10 most-converted hex codes and their RGB equivalents — pure primaries, pure secondaries, and two real-world brand colors from the Tailwind palette.

Black

#000000 rgb(0 0 0)

Pure black. All three channels at zero — the absence of emitted light. RGB triple (0, 0, 0).

#000000 rgb(0 0 0)

Pure black on a screen is rarely the right design choice — try `#111` or OKLCH lightness 0.1-0.15 for softer body text.

Need OKLCH instead? Try the dedicated hex to OKLCH converter for perceptually-uniform output.

White

#FFFFFF rgb(255 255 255)

Pure white. All three channels at their maximum value (255). The brightest color in sRGB.

#FFFFFF rgb(255 255 255)

Pure white backgrounds can produce eye strain in dark environments — consider `#fafafa` or OKLCH 0.98 for warmer alternatives.

Need OKLCH instead? Try the dedicated hex to OKLCH converter for perceptually-uniform output.

Red

#FF0000 rgb(255 0 0)

Pure red. R channel at maximum, G and B at zero. The first of the three sRGB primaries.

#FF0000 rgb(255 0 0)

Pure red is highly saturated and rarely fits a brand palette — most "red" brand colors sit closer to #DC2626 or #E53935.

Need OKLCH instead? Try the dedicated hex to OKLCH converter for perceptually-uniform output.

Green

#00FF00 rgb(0 255 0)

Pure green. G channel at maximum, R and B at zero. CSS named color `lime` (not `green`, which is #008000).

#00FF00 rgb(0 255 0)

The CSS keyword `green` resolves to #008000 (half-bright), not #00FF00 — a frequent source of confusion. Use `lime` for pure RGB green.

Need OKLCH instead? Try the dedicated hex to OKLCH converter for perceptually-uniform output.

Blue

#0000FF rgb(0 0 255)

Pure blue. B channel at maximum, R and G at zero. The third sRGB primary.

#0000FF rgb(0 0 255)

Pure blue on a white background fails WCAG AA contrast (3.7:1) — consider darker brand blues like #1D4ED8 (Tailwind blue-700) for body text.

Need OKLCH instead? Try the dedicated hex to OKLCH converter for perceptually-uniform output.

Cyan

#00FFFF rgb(0 255 255)

Cyan — green and blue at maximum, red at zero. One of three sRGB secondaries. CSS named color `cyan` (or equivalently `aqua`).

#00FFFF rgb(0 255 255)

Cyan and aqua are exact synonyms in CSS — both resolve to #00FFFF. Pick one and stay consistent across your stylesheet.

Need OKLCH instead? Try the dedicated hex to OKLCH converter for perceptually-uniform output.

Magenta

#FF00FF rgb(255 0 255)

Magenta — red and blue at maximum, green at zero. CSS named color `magenta` (or equivalently `fuchsia`).

#FF00FF rgb(255 0 255)

Magenta and fuchsia are exact synonyms in CSS — both resolve to #FF00FF. Common in test patterns and developer-tool overlays.

Need OKLCH instead? Try the dedicated hex to OKLCH converter for perceptually-uniform output.

Yellow

#FFFF00 rgb(255 255 0)

Yellow — red and green at maximum, blue at zero. The brightest of the three sRGB secondaries by perceived luminance.

#FFFF00 rgb(255 255 0)

Yellow is the highest-luminance non-white color on screen — yellow text on white backgrounds is nearly invisible, even though hex looks fine on paper.

Need OKLCH instead? Try the dedicated hex to OKLCH converter for perceptually-uniform output.

Tailwind blue-500

#3b82f6 rgb(59 130 246)

Tailwind CSS's default blue-500 brand color — the canonical "web blue" of the mid-2020s. Used in countless dashboards, marketing sites, and admin tools.

#3b82f6 rgb(59 130 246)

Tailwind v4 redefines blue-500 in OKLCH (`oklch(0.629 0.193 263.4)`) for perceptually-uniform ramps — the hex stays the same as a fallback.

Need OKLCH instead? Try the dedicated hex to OKLCH converter for perceptually-uniform output.

Tailwind rose-500

#f43f5e rgb(244 63 94)

Tailwind CSS's default rose-500 — a high-saturation pink-red used commonly for accent buttons, alert states, and brand contrast.

#f43f5e rgb(244 63 94)

Rose-500 passes WCAG AA (4.6:1) against white for large text but fails for body text — pair with rose-600 (#e11d48) or darker for body copy on white.

Need OKLCH instead? Try the dedicated hex to OKLCH converter for perceptually-uniform output.

How to Use the Hex to RGB Converter

  1. 1

    Paste a hex code into the HEX field

    Drop any hex value into the HEX input — with or without the leading `#`, in 3-digit shorthand (`#F73`), 6-digit full form (`#FF5733`), 4-digit alpha shorthand (`#F738`), or 8-digit alpha full form (`#FF5733CC`). The tool normalizes all five input shapes to the same canonical color internally. Capitalization doesn't matter (`#ff5733` and `#FF5733` parse identically). Invalid characters or wrong digit counts produce a quiet inline error; valid hex updates every other format field in real time.

  2. 2

    Read the RGB tuple from the RGB field

    The RGB field below the HEX field shows the matching `rgb()` value in CSS Color 4's modern space-separated syntax: `rgb(255 87 51)` for an opaque color, `rgb(255 87 51 / 0.5)` for an alpha-bearing one. Each channel is a 0-255 integer; alpha is normalized to 0-1. The values are bit-exact — `parseInt('FF', 16)` returns 255, with no float arithmetic involved, so a round-trip back to hex produces the original input verbatim.

  3. 3

    Click Copy to grab the RGB string

    Each format card has a Copy button on the right. One click and the value lands on your clipboard — the button label briefly flashes "Copied!" so you know. The copied string is the canonical CSS Color 4 syntax (`rgb(255 87 51)`); if your target needs the legacy comma form, the conversion is mechanical (replace spaces with `, `). For platform-specific output (SwiftUI, Compose, Flutter, Tailwind v4), use the Copy as code section below the picker.

  4. 4

    Also visible: HSL, OKLCH, OKLAB, CMYK, named color

    The same hex you paste lights up the other format fields too — HSL for legacy CSS, OKLCH and OKLAB for perceptually-uniform design systems, HSV and HWB for designer color-picker workflows, CMYK for print estimates, and the closest CSS named color for documentation and prose. You're never locked into hex → RGB only; if you also need the OKLCH triple to drop into a Tailwind v4 `@theme` block, it's right there in the OKLCH field with its own Copy button.

  5. 5

    Use the picker for visual tweaks

    Below the format grid is an SL square + hue slider + alpha slider for visual exploration. Drag any control and every text field updates in real time, including the HEX and RGB you started with. On Chromium-based browsers (Chrome, Edge, Brave) the EyeDropper button activates the native `EyeDropper` API for sampling any pixel on screen, including outside the browser window — useful when you want to capture a hex from another app's UI without screenshotting first.

Common Hex / RGB Mistakes

Treating 3-Digit Hex as Left-Padded

3-digit shorthand `#RGB` expands by *duplicating each digit*, not by left-padding with zeros. `#F73` becomes `#FF7733` (bright orange), not `#000F73` (dark blue). This is the single most-mistaken corner of CSS color syntax; beginners frequently assume the shorthand is some kind of zero-pad and end up with wildly wrong colors. The same rule applies to 4-digit alpha shorthand `#RGBA` — each digit duplicates to form the 8-digit equivalent.

✗ Wrong
Assume #F73 left-pads to #000F73:
expected: dark blue rgb(0, 15, 115)
actual:   bright orange rgb(255, 119, 51)
✓ Correct
3-digit shorthand duplicates each digit:
#F73 → #FF7733 → rgb(255, 119, 51)
Verified by the tool's live expansion as you type.

Forgetting padStart When Serializing RGB to Hex

Converting RGB back to hex requires each channel's `toString(16)` to be left-padded to 2 digits. Without `padStart(2, '0')`, single-digit channel values produce invalid hex: `rgb(5, 87, 51)` would serialize as `#55733` (5 characters) instead of `#055733` (6 characters). Many ad-hoc converters skip the pad and produce broken output for any channel under 16. The standard idiom is `value.toString(16).padStart(2, '0')` for each of R, G, B.

✗ Wrong
Skip padStart:
[5, 87, 51].map(v => v.toString(16)).join('') → '55733'
Produces invalid 5-character hex.
✓ Correct
Use padStart(2, '0'):
[5, 87, 51].map(v => v.toString(16).padStart(2, '0')).join('') → '055733'
Valid 6-character hex; works correctly for all channel values 0-255.

Confusing 8-Digit Hex Alpha Ordering

CSS 8-digit hex is `#RRGGBBAA` — alpha is the *trailing* pair. Some color libraries (notably older Android `Color.parseColor()`) use the opposite ordering `#AARRGGBB` with alpha as the *leading* pair, which is incompatible with CSS hex. A web hex `#FF573380` (orange at 50% alpha) interpreted as `#AARRGGBB` becomes alpha=255, R=87, G=51, B=128 — a dark cyan at full opacity. Always verify the target platform's alpha ordering before round-tripping 8-digit hex.

✗ Wrong
Paste CSS 8-digit hex into legacy Android Color.parseColor():
#FF573380 interpreted as #AARRGGBB
→ wrong color and wrong alpha entirely.
✓ Correct
Use the target platform's documented format:
for Android Compose: Color(0xFFFF5733) with alpha as first byte
for CSS: #FF573380 with alpha as last byte
Don't cross-paste between the two without re-ordering.

Averaging RGB Channels Directly for Blending

RGB channels are gamma-encoded, not linear. Averaging two RGB values gives a perceptually-wrong midpoint. `(255, 0, 0)` averaged with `(0, 255, 0)` produces `(127, 127, 0)`, a muddy dark olive, not the bright yellow midpoint you'd expect from mixing red and green light. For correct blending, decode to linear-RGB first via the sRGB transfer function (CSS Color 4 §11.2), average in linear space, then re-encode. Or work in OKLAB / OKLCH where perceptual distance is uniform.

✗ Wrong
Average gamma-encoded RGB directly:
(rgb(255,0,0) + rgb(0,255,0)) / 2 = rgb(128, 128, 0)
Looks like dark olive, not bright yellow.
✓ Correct
Average in linear-RGB:
decode → linear-RGB → average → re-encode → rgb(188, 188, 0)
Visibly bright yellow, matching what physical light mixing produces.

Who Uses Hex to RGB

Frontend Devs Converting Figma Hex to Canvas RGB Calls
Figma exports hex, but `CanvasRenderingContext2D.fillStyle` accepts both hex and `rgb()` — and when you're doing per-channel arithmetic (gradients, blending, image manipulation), having the channel integers directly is faster than re-parsing the hex each time. Paste the hex once, copy the `rgb(255 87 51)` tuple, plug into the canvas call. Zero hex-parsing code needed on your side.
Designers Translating Web Hex to Photoshop / Illustrator RGB
Adobe's Color picker takes 0-255 integers across three channel boxes as its native input. Paste the web hex into this tool, read off the R / G / B integers, type them into Photoshop. Matches the original web color exactly without a screenshot-and-eyedropper detour. Useful when a designer needs to mock up a web color in a print-aware Adobe layout app.
Game Devs Loading Brand Hex into Unity / Unreal RGB APIs
Unity's `Color` and Unreal's `FLinearColor` both take 0-1 normalized floats. Paste the brand hex, read the 0-255 integers, divide by 255 (or use the tool's normalized-float output via Copy as code). The conversion is mechanical but mistake-prone when done by hand — typing `(255, 87, 51)` into a constructor that expected `(1.0, 0.341, 0.2)` produces a clipped-white color and a confused tweet. The tool surfaces both forms.
Hardware Devs Programming Addressable LED Strips
WS2812, APA102, and other addressable RGB LED strips take 0-255 integer channels per LED. Paste the brand hex for the wall-mounted product display, read the RGB triple, drop into the controller's color array. Useful when the marketing team specifies a hex and the firmware engineer needs the channel values for a `pixels.setPixelColor(i, r, g, b)` call.
Accessibility Engineers Auditing Brand Color Readability
WCAG 2.1 contrast checking takes RGB inputs internally. Paste the brand hex, get the matching RGB plus the WCAG ratio against white and black plus the APCA Lc score in one screen. If the brand color flunks the 4.5:1 body-text floor, the perceptually-uniform OKLCH field next door makes it easy to bump L until contrast clears without losing brand identity.
Designers Embedding Email Templates With Inline RGB
Some email clients (Outlook on Windows, older Gmail mobile) parse hex inconsistently in HTML attributes — `` may render as black on certain platforms. The reliable fallback is the equivalent RGB `rgb(255, 87, 51)` form inline. Paste the brand hex, copy the RGB string in legacy comma syntax (manual replace from the modern space form), drop into the email template's `style` attribute.
Developers Documenting Brand Tokens With Both Formats
Design-token documentation often shows the same color in both formats: hex for the CSS code block, RGB for the prose annotation ("the brand red is `#FF5733`, equivalent to RGB 255 / 87 / 51"). Having both visible side-by-side lets a doc writer copy each in one pass instead of running two tools. The shareable URL hash also lets readers click through to the exact color under discussion.
QA Engineers Verifying Pixel-Color Snapshots
Visual regression tests often assert specific RGB values against rendered pixels (`expect(pixel.r).toBe(255)`). When the spec is given as a hex ("buttons must render as `#FF5733`"), the QA engineer needs the matching RGB integers to write the assertion. Paste the hex, read off R / G / B, plug into the test. The bit-exactness of the conversion means the test won't flake on float-drift differences.

Hex to RGB Math & Parsing

parseInt(hex, 16) Is the One-Line Implementation
The entire hex-to-RGB conversion fits in one expression per channel: `parseInt(hex.slice(1, 3), 16)` for R, `parseInt(hex.slice(3, 5), 16)` for G, `parseInt(hex.slice(5, 7), 16)` for B. JavaScript's `parseInt` with radix 16 reads a hex string into a decimal integer in the 0-255 range with no float involvement. The reverse direction (`value.toString(16).padStart(2, '0')`) is equally one-liner — the `padStart(2, '0')` is the easy-to-forget detail that catches single-digit channel values like 5 → `'05'` instead of `'5'`.
Shorthand Expansion: Digit-Duplication, Not Left-Pad
CSS spec defines 3-digit shorthand as `#RGB` expanding to `#RRGGBB` by duplicating each digit. `#F73` → `#FF7733`, *not* `#000F73`. The same rule applies to 4-digit alpha shorthand `#RGBA` → `#RRGGBBAA`. This is one of the most-mistaken corners of CSS color syntax — beginners frequently assume `#F73` left-pads to `#000F73`, which would produce a different color entirely (a desaturated dark blue rather than the intended bright orange). The tool's expansion behavior makes the rule visible at a glance.
8-Digit Alpha: Trailing Pair, Divided by 255
8-digit hex `#RRGGBBAA` encodes alpha as a 2-digit hex pair after the RGB triple, parsed identically and then divided by 255 to produce a 0-1 float. `#FF573380` parses to alpha = `0x80 / 255 = 128 / 255 = 0.5019607843137255`. The CSS Color 4 spec uses 4 decimal places of precision for the output (`/ 0.502`); the tool follows the same convention. 8-digit hex shipped in all evergreen browsers in 2018 (Chrome 62, Firefox 49, Safari 9.1, Edge 79). Pre-2018 fallback is `rgba()`.
RGB Output: CSS Color 4 Space-Separated by Default
The tool emits `rgb(255 87 51)` (modern space-separated) by default rather than the legacy `rgb(255, 87, 51)` (CSS 1 comma-separated). Both shapes are valid and interchangeable in every evergreen browser since 2018. The modern syntax aligns with CSS Color 4's other functional notations (`hsl()`, `lab()`, `oklch()`, `color()`) which all use space separation and slash-for-alpha. The legacy comma form is one mechanical replace away if your toolchain requires it; rgba() is still the right fallback for IE 9-11 contexts.
OKLCH Internal Source-of-Truth for Round-Trip Stability
Even though this spoke targets HEX → RGB specifically, the shared underlying converter holds the canonical color as an OKLCH triple internally. This means HEX → RGB → HSL → OKLAB → CMYK → HEX round-trips without per-step float drift; legacy converters that route through HSL or sRGB as their pivot accumulate rounding error at each conversion. The choice of OKLCH (over OKLAB) preserves Hue as a stable axis so dragging the hue slider doesn't accidentally cross-fade through gray. Per Björn Ottosson's 2020 OKLAB paper.
Channel Encoding: 8-Bit Unsigned, sRGB Gamma-Encoded
Each RGB channel is an 8-bit unsigned integer (0-255), encoded in the sRGB color space defined by IEC 61966-2-1 (1996). The values are *gamma-encoded* — meaning the relationship between channel value and perceived brightness is non-linear, following the piecewise sRGB transfer function (roughly a 2.4 exponent with a small linear segment near zero). This matters when you're doing color math: averaging two RGB values in their gamma-encoded form gives the wrong perceptual midpoint. For correct color blending, decode to linear-RGB first (CSS Color 4 §11.2), then average, then re-encode. The tool's OKLCH internal model makes this transparent.

Best Practices for Hex / RGB Workflows

Use Modern Space-Separated RGB Syntax in New Code
CSS Color 4's `rgb(255 87 51)` (space-separated) and `rgb(255 87 51 / 0.5)` (slash for alpha) are the canonical syntaxes for code shipping in 2025 and forward. The legacy comma forms `rgb(255, 87, 51)` and `rgba(255, 87, 51, 0.5)` are still supported everywhere but are deprecated stylistically in CSS Color 4. Use the modern syntax in new stylesheets; keep `rgba()` only for IE 9-11 fallback contexts where you genuinely need legacy support.
Verify 8-Digit Hex Support Before Shipping Alpha-Bearing Codes
8-digit hex with alpha (`#FF573380`) shipped in all evergreen browsers in 2018, but legacy CSS preprocessors and some older design tools silently truncate the alpha pair to 6-digit hex. The result: a color you expected to be 50% transparent renders as fully opaque. Before shipping 8-digit hex in production, verify the target parser handles it; for legacy targets, fall back to explicit `rgba(255, 87, 51, 0.5)` syntax which has been supported since IE 9.
Don't Average RGB Channels Directly for Color Math
RGB channels are gamma-encoded — averaging two RGB values gives the wrong perceptual midpoint. `(255, 0, 0)` averaged with `(0, 255, 0)` produces `(127, 127, 0)`, a muddy dark olive, not the visually-bright yellow midpoint you'd expect. For correct color blending, decode to linear-RGB first (CSS Color 4 §11.2), then average, then re-encode. Or, better, work in OKLAB or OKLCH where perceptual distance is uniform — that's exactly what design-system palette generators do.
Prefer Hex for Design-Token Source, RGB for Hardware
When you're writing a design token spec, prefer hex (or OKLCH) as the canonical form — they're terser and fit cleanly in JSON or YAML. When the consuming code does per-channel arithmetic (canvas calls, image manipulation, hardware LED drivers, OpenGL color attributes), the RGB integer form is faster to consume. The two formats describe the same color; the choice is purely about who's reading and writing, not about correctness. This tool's simultaneous-field view makes both equally cheap.
Document Alpha Explicitly in Token Names
When a design token includes alpha (e.g. a 50%-opacity overlay), don't bury the alpha in an 8-digit hex like `#000000CC` — split the token into `--color-overlay-base: #000000` and `--color-overlay-alpha: 0.8`, or use the explicit RGBA form. Burying alpha in hex makes the token unreadable to anyone scanning the file and makes per-token alpha tweaks impossible without re-parsing the hex first. Token-system clarity beats brevity when the cost is one extra variable.
Use the URL Hash to Share Live Color Decisions
Every color change updates the URL hash as `#hex=ff5733` automatically. Copy the URL into a Slack thread or GitHub issue and anyone who opens it lands on the same color with the same RGB tuple. This is more reliable than pasting a hex string in chat — recipients sometimes typo characters when manually entering the value — and lets a design-review thread reference an exact color rather than "the orange we discussed Tuesday." The hash is never transmitted to the server.

Frequently Asked Questions

How do I convert a hex code to RGB?
Split the 6-digit hex into three 2-digit pairs and read each pair as a base-16 number from 0-255. `#FF5733` becomes R=`FF`=255, G=`57`=87, B=`33`=51, giving `rgb(255 87 51)`. 3-digit shorthand `#F73` expands by duplicating each digit to `#FF7733` before splitting. This tool does the conversion live as you type — paste any hex (with or without the `#`, 3-digit, 6-digit, 4-digit, or 8-digit with alpha) and the RGB field updates instantly with the matching `rgb()` value.
Is hex the same as RGB?
They encode the same information in different notation. Both describe a color as three channels (red, green, blue) on the 0-255 scale, anchored to the sRGB color space. Hex packs the three channels into a 6-character base-16 string (`#FF5733`); the `rgb()` function spells them out in decimal (`rgb(255 87 51)`). They round-trip losslessly — the same color goes hex → RGB → hex without drift. Hex is shorter for CSS variables; `rgb()` supports an alpha channel via `rgba()` and CSS Color 4 percentage syntax.
How do you read a hex color code?
A hex color has 6 hexadecimal digits after the `#`, grouped as **RR GG BB**. Each pair encodes one channel from `00` (none, 0 in decimal) to `FF` (full, 255 in decimal). `#FF0000` is pure red, `#00FF00` is pure green, `#0000FF` is pure blue. An 8-digit hex (`#FF5733CC`) adds an alpha pair at the end — `CC` = 204/255 ≈ 80% opacity. The 3-digit shorthand `#F73` expands each digit by duplicating it: `#F73` is identical to `#FF7733`.
What is the formula for hex to RGB?
For each 2-digit hex pair, multiply the first digit by 16 and add the second: `FF` = 15×16 + 15 = 255, `57` = 5×16 + 7 = 87, `33` = 3×16 + 3 = 51. In JavaScript: `parseInt('FF', 16)` returns 255 directly. In CSS the reverse direction is built into the parser — `rgb(255 87 51)` and `#FF5733` are interchangeable anywhere a `` is accepted. There's no rounding loss in either direction: 16² = 256, exactly matching the 0-255 byte range each channel occupies.
Why use hex instead of RGB?
Three reasons: it's shorter (`#FF5733` vs `rgb(255, 87, 51)`), it's the default export from every design tool (Figma, Sketch, Photoshop), and it's the format front-end developers learn to recognize on sight — most can identify `#3b82f6` as Tailwind blue-500 without looking it up. Reach for `rgb()` (or the modern space-separated `rgb(R G B / A)` syntax from CSS Color 4) when you need alpha transparency, when you're computing a color from JavaScript channel values, or when explicit percentage syntax improves readability in a stylesheet.
Can hex codes have alpha?
Yes — use 8-digit hex (`#RRGGBBAA`) or 4-digit shorthand (`#RGBA`). The alpha pair follows the same 0-`FF` scale: `#FF573300` is fully transparent, `#FF5733FF` is fully opaque, `#FF573380` is roughly 50%. CSS 4-digit and 8-digit hex with alpha shipped natively in all evergreen browsers in 2018 (Chrome 62, Firefox 49, Safari 9.1, Edge 79). For older parsers and legacy CSS preprocessors that silently truncate the alpha pair, fall back to `rgba(255, 87, 51, 0.5)`, which has been supported since IE 9.
How many colors can hex represent?
6-digit hex represents exactly **16,777,216** colors — 256 values per channel cubed (256³). With 8-digit hex including alpha, the addressable space is 256⁴ ≈ 4.3 billion, but the color content is still 16.7M; the extra dimension is opacity. The human eye can distinguish roughly 10 million colors, so 24-bit sRGB has been marketed as "truecolor" since the 1990s. Modern wide-gamut displays (Display P3, Rec.2020) cover more of the visible spectrum, but hex itself is sRGB-bound — use OKLCH or `color(display-p3 ...)` for wide-gamut values.
How do I convert RGB to hex?
Reverse the formula: divide nothing, just convert each channel integer to its 2-digit base-16 representation and concatenate. In JavaScript: `[255, 87, 51].map(v => v.toString(16).padStart(2, '0')).join('')` returns `'ff5733'`, then prepend `#`. The `padStart(2, '0')` matters — without it, single-digit values like `5` would serialize as just `'5'` instead of `'05'`, producing an invalid hex. For the reverse direction in this tool's family, use the dedicated RGB to hex converter.

Related Tools

View all tools →