HEX to RGB Converter by Klipto

Convert a HEX color to RGB, HSL, CSS, SwiftUI and UIColor instantly. Free, in your browser, or download Klipto to convert colors on every paste on your Mac.

100% in your browser. Nothing is uploaded, logged, or stored.

Split a six-digit hex code into three pairs and read each pair as a base-16 number from 0 to 255. #394DFE is rgb(57, 77, 254), because 39 is 57, 4D is 77 and FE is 254. The converter above does it the moment you paste a code.

Hex and RGB are two spellings of the same sRGB color, so nothing shifts in the swap. Stylesheets and design tools want hex. Code usually wants channel numbers or a native color type, so this page also gives you the Apple, CSS variable and Tailwind forms that most converters skip.

Meet Klipto

Convert colors on every paste, not in a browser tab.

Klipto is a native macOS clipboard manager. Copy any HEX and its preview panel offers RGB, HSL, SwiftUI, UIColor, CSS and Tailwind — right where you paste, offline.

See what Klipto does

How hex becomes RGB

Three steps, and no rounding until the end.

Split into pairs: six hex digits hold three bytes, one per channel. #394DFE gives 39, 4D and FE for red, green and blue.

Read each pair in base 16: digits run 0-9 then A-F, where A is 10 and F is 15. Each pair covers 0 to 255. 39 is (3 x 16) + 9 = 57. 4D is (4 x 16) + 13 = 77. FE is (15 x 16) + 14 = 254.

Assemble: rgb(57, 77, 254).

Shorthand codes use three digits, and you expand them by doubling each one. #39F becomes #3399FF, which reads as rgb(51, 153, 255).

Eight-digit codes add a fourth pair for alpha, #RRGGBBAA. The alpha byte is round(opacity x 255) in hex, so half opacity is 128, written 80. One difference worth knowing: hex alpha on a background color leaves the element's text and child elements at full opacity, while the CSS opacity property fades them too.

Every format from one hex code

Klipto reads the format you copied, so a hex code, an hsl() string and a Swift initializer all produce the same row of alternatives. Detection happens at copy time. A color sitting inside a longer sentence is left alone, because the value has to be the thing you copied.

The set of output formats is fixed at nine on purpose. Nine covers CSS, Swift and Tailwind work. A dropdown of forty color spaces takes longer to operate than typing the number by hand.

Web notation: rgb(57, 77, 254), rgba(57, 77, 254, 1) and hsl(234, 99%, 61%), where hue is degrees and the other two are percentages.

Normalized channels: 0.224, 0.302, 0.996, each byte divided by 255. SwiftUI wants floats in that range, not bytes.

Apple types: Color(.sRGB, red: 0.224, green: 0.302, blue: 0.996, opacity: 1) for SwiftUI, UIColor(red: 57/255, green: 77/255, blue: 254/255, alpha: 1) for UIKit, and NSColor(srgbRed: 57/255, green: 77/255, blue: 254/255, alpha: 1) for AppKit.

CSS variable and Tailwind: --brand: #394dfe;, read back through var(--brand), plus the nearest class in the Tailwind palette.

Two of those hide a trap. NSColor has separate initializers per color space, and they produce visibly different colors on screen from the same three numbers. deviceRed: is device-dependent and skips ColorSync. srgbRed: pins sRGB, which is what Xcode asset catalogs and design files assume. Pick the sRGB one and the paste matches the mockup.

Tailwind has no exact hex lookup. Matchers compute CIEDE2000 (ΔE00) perceptual distance against the palette, and a ΔE under 2.0 is indistinguishable to the eye. Tailwind v4 also redefined its default palette in oklch() for the P3 gamut in 2025, so treat any hex-to-Tailwind answer as the nearest color rather than the same one.

Hex to HSL

HSL takes more work, because it is not a direct byte read. Convert to RGB first, then divide each channel by 255. For #3498DB that is 52, 152, 219, which become 0.20, 0.60, 0.86.

Take the max and min of those three. Lightness is (max + min) / 2, about 0.53 here. Saturation is 0 when max equals min, (max - min) / (max + min) when L is at most 0.5, and (max - min) / (2 - max - min) above that. Hue comes from whichever channel is the max, scaled onto the 0-360 degree wheel.

Using the converter

1. Paste or type a hex code above. Three, six and eight digits all work, with or without the #.

2. Read the RGB, RGBA and HSL values, or scroll to the developer formats.

3. Copy the line you need. Everything runs in your browser, so no code is uploaded.

This free tool vs Klipto

This free web toolKlipto
RGB, RGBA, HSLYes, one code at a timeYes, on the paste
SwiftUI, UIColor, NSColorYesYes
CSS variable and Tailwind classYesYes
Detects a color when you copy itNo, you paste it inYes
Works in Xcode, VS Code, Figma, SlackThis page onlyAnywhere you copy
Needs a browser tabYesNo
Clipboard history and other transformsNoYes, 20-plus transforms
PlatformAny browsermacOS 14+
PriceFreeFree tier, $19.99 one-time

For one value a month, a browser tab is fine and I would not install anything for it. The tab stops being fine at ten colors a day, when the copy-open-paste-copy-return loop is most of the work. You can get it automatically on every paste with Klipto instead: it detects the color as you copy it, offline, and puts the other eight formats in the paste preview.

Frequently asked questions

How do I convert a hex color to RGB?

Split the code into three two-character pairs for red, green and blue, then read each pair as a base-16 number from 0 to 255. `#394DFE` gives `rgb(57, 77, 254)`. The converter above does this as you type.

What is the difference between hex and RGB?

None in the color itself. `#394DFE` and `rgb(57, 77, 254)` render identically, because both describe the same sRGB value. Hex is compact for CSS and design tools, and RGB channel numbers are easier to adjust in code.

How many colors can hex represent?

A six-digit hex code carries 256 shades per channel across three channels. That is 256 x 256 x 256, or 16,777,216 colors, usually written as 16.7 million.

How do I convert hex to RGBA?

Convert the hex to RGB and add an alpha from 0 to 1, so `#394DFE` at full opacity is `rgba(57, 77, 254, 1)`. Starting from an eight-digit code, divide the last pair by 255 to get the alpha, which turns `80` into about 0.5.

How do I convert a 3-digit shorthand hex?

Double each digit, then convert normally. `#39F` becomes `#3399FF`, which reads as `rgb(51, 153, 255)`. Shorthand can only describe channels whose two digits repeat.

What does an 8-digit hex code mean?

It is `#RRGGBBAA`, where the final pair sets opacity. The alpha byte equals `round(opacity x 255)` in hex, so `80` is roughly 50%. Browsers have supported it since Chrome 62, Firefox 49 and Safari 10.

How do I use a hex color in SwiftUI?

Divide each byte by 255 and pin the color space: `Color(.sRGB, red: 0.224, green: 0.302, blue: 0.996, opacity: 1)` for `#394DFE`. Leaving out `.sRGB` can shift the rendered color.

Why does my pasted NSColor look wrong?

The device-dependent initializers and `NSColor(srgbRed:green:blue:alpha:)` produce different on-screen colors from identical numbers. Use the sRGB one to match hex from a design file or an asset catalog.

Is the converter free and private?

Yes to both. It runs entirely in your browser, so nothing is uploaded, logged or stored, and there is nothing to install.

Get Klipto for Mac

Free for 14 days · no card, no account required · 5 MB

Download Klipto