How to convert HEX to RGB on a Mac

The arithmetic takes ten seconds. Doing it forty times a day is the problem.

Each pair of hex digits is one channel counted in base 16, from 00 to FF, which is 0 to 255 in decimal. So #394DFE comes out as rgb(57, 77, 254). If you want the number without doing any arithmetic, the macOS colour picker has a hex field built in, and it costs nothing.

The arithmetic, once

39 means three sixteens plus nine, so 57. 4D means four sixteens plus thirteen, so 77. FE means fifteen sixteens plus fourteen, so 254. Red, green, blue, in that order, always two digits each.

Three-digit codes are shorthand. Each digit doubles, so #F53 is #FF5533. Eight digits means an alpha channel is riding along at the end, and #394DFE80 is that same blue at about 50 percent opacity.

The free route: the macOS colour picker

1. Open a colour well anywhere. TextEdit, Format, Font, Colour is the one I reach for.

2. Switch to the sliders tab and choose RGB Sliders.

3. Type the code into the Hex Colour field.

4. Read the three numbers off the sliders.

The chips you see are built at copy time, not at paste time. Klipto reads the value the moment it lands in the clipboard, works out whether it is HEX, rgb(), hsl() or a Swift initializer, and has the other notations ready before you open the popup.

Detection matches a colour value, not a fragment of a sentence. A hex code sitting inside a paragraph of prose is left alone, so a copied changelog entry does not suddenly turn into a Tailwind class.

That picker is fine for one value. It stops being fine at the fortieth, because every conversion is four clicks and a window you then have to close. That is the part I got tired of, so I built the conversion into the paste itself.

Doing it on the way to Command-V

Copy the code, open Klipto with ⌥⌘V, and the preview shows the same colour written every other way. Tap a chip, press ⌘V, and that notation goes into the file.

What comes out: rgb(57, 77, 254), rgba(57, 77, 254, 1.0), hsl(234, 99%, 61%), a SwiftUI Color(red:green:blue:), UIColor, NSColor, a CSS custom property, and a Tailwind arbitrary-value class carrying your exact code.

It runs in both directions. Copy an hsl() string or a Color(...) initializer and you get the hex back. There is no input format to declare.

The trap: NSColor and colour spaces

NSColor(red:green:blue:alpha:) builds the colour in deviceRGB, which is not sRGB. On a wide-gamut display those three numbers render as a visibly different colour from the hex code you started with. Change it to NSColor(srgbRed:green:blue:alpha:) and it matches.

Klipto pastes the plain red: form and does not guess your project's colour space. I would rather tell you about the swap than pick wrong on your behalf. The SwiftUI Color(red:green:blue:) chip has no such problem in a normal sRGB project.

What I use

For a single value, the system picker. For a value I need in a browser with nothing installed, try it free in your browser. For the forty conversions a day that come with building a UI in Swift and shipping a website beside it, Klipto's colour conversion on paste removes the round trip entirely, offline, in whatever editor already has focus.

Maccy is free and excellent if all you want is clipboard history. It does not convert anything, which is exactly why I forked it.

Frequently asked questions

What is `#394DFE` in RGB?

`rgb(57, 77, 254)`. The pairs convert separately: `39` is 57, `4D` is 77, `FE` is 254.

Can macOS convert a hex code without an app?

Yes. Any colour picker has a Hex Colour field under RGB Sliders. Paste the code there and read the RGB values off the sliders.

What does an eight-digit hex code mean?

The last two digits are alpha, from `00` for fully transparent to `FF` for fully opaque. Klipto parses 3, 4, 6 and 8-digit forms.

Why does my pasted NSColor look wrong?

It was built in deviceRGB rather than sRGB, and the two differ on wide-gamut screens. Use `NSColor(srgbRed:...)`.

Get Klipto for Mac

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

Download Klipto