hex to SwiftUI Color

SwiftUI takes 0–1 components. It has no hex initialiser built in, which is why this conversion comes up so often.

Hue
Alpha
100%
SwiftUI Color
Color(red: 0.259, green: 0.529, blue: 0.961)

Paste a hex value — other formats work too.

Need every format at once? Open in the full picker

Worked examples

Common colours converted from hex to SwiftUI Color, computed with the same engine the picker uses.

ColourhexSwiftUI ColorCopy
Pure red#ff0000Color(red: 1, green: 0, blue: 0)
Pure green#00ff00Color(red: 0, green: 1, blue: 0)
Pure blue#0000ffColor(red: 0, green: 0, blue: 1)
White#ffffffColor(red: 1, green: 1, blue: 1)
Mid grey#808080Color(red: 0.502, green: 0.502, blue: 0.502)
Black#000000Color(red: 0, green: 0, blue: 0)
Interface blue#4287f5Color(red: 0.259, green: 0.529, blue: 0.961)
Success green#22c55eColor(red: 0.133, green: 0.773, blue: 0.369)
Danger red#ef4444Color(red: 0.937, green: 0.267, blue: 0.267)
Warning amber#f59e0bColor(red: 0.961, green: 0.62, blue: 0.043)
Editor black#1e1e1eColor(red: 0.118, green: 0.118, blue: 0.118)
Warm sand#e9c46aColor(red: 0.914, green: 0.769, blue: 0.416)

How the conversion works

SwiftUI takes 0–1 components. It has no hex initialiser built in, which is why this conversion comes up so often.

Both formats are computed from a single canonical representation — CIE XYZ with a D65 white point, held in floating point — rather than by chaining one format into the next. That matters because chained conversions accumulate rounding error, and because it means a colour that cannot be represented in the target format is handled deliberately rather than by accident.

When the source describes a colour outside the target's gamut, chroma is reduced in OKLCh while lightness and hue are held, following the CSS Color 4 gamut mapping algorithm. Clipping each channel independently would be simpler but visibly shifts hue on saturated colours.

Related conversions