Skip to the color picker

HSL to SwiftUI converter

Paste a HSL value, get SwiftUI instantly. Any other format works too.

Read as HSL

SwiftUI valueColor(red: 1, green: 0.341, blue: 0.2)
SwiftUI to HSL

Adjust the color

11°
100%

68%
0.210
34°

Every other format

HSL to SwiftUI examples

ColorHSLSwiftUI
hsl(0, 100%, 50%)Color(red: 1, green: 0, blue: 0)
hsl(120, 100%, 50%)Color(red: 0, green: 1, blue: 0)
hsl(240, 100%, 50%)Color(red: 0, green: 0, blue: 1)
hsl(0, 0%, 100%)Color(red: 1, green: 1, blue: 1)
hsl(0, 0%, 0%)Color(red: 0, green: 0, blue: 0)
hsl(0, 0%, 50.2%)Color(red: 0.502, green: 0.502, blue: 0.502)
hsl(10.59, 100%, 60%)Color(red: 1, green: 0.341, blue: 0.2)
hsl(217.22, 91.22%, 59.8%)Color(red: 0.231, green: 0.51, blue: 0.965)
hsl(160.12, 84.08%, 39.41%)Color(red: 0.063, green: 0.725, blue: 0.506)
hsl(37.69, 92.13%, 50.2%)Color(red: 0.961, green: 0.62, blue: 0.043)
hsl(258.31, 89.53%, 66.27%)Color(red: 0.545, green: 0.361, blue: 0.965)
hsl(330.37, 81.19%, 60.39%)Color(red: 0.925, green: 0.282, blue: 0.6)

About HSL and SwiftUI

HSL describes hue in degrees, saturation and lightness in percent. It is easy to read, but its lightness is not perceptually even: yellow at 50% looks much lighter than blue at 50%.

SwiftUI describes a color with red, green and blue from 0 to 1, written as Color(red: 1, green: 0.341, blue: 0.2). Opacity is added with the opacity parameter.

How the conversion works

We read the HSL value, convert it to CIE XYZ with the matrices from the CSS Color 4 specification and then into SwiftUI. Values outside the target gamut are mapped by the CSS Color 4 algorithm, which keeps lightness and hue and reduces chroma.

Questions and answers

How do I convert HSL to SwiftUI?

Paste or type a HSL value into the field above. PickShade converts it with the CSS Color 4 formulas as you type, and one click copies the SwiftUI value.

Is the HSL to SwiftUI conversion exact?

The math is exact and the result is rounded only for display, with enough digits to convert back to the same color. If the color does not fit the target gamut, PickShade warns you and shows the nearest color that fits.

Can I get other formats at the same time?

Yes. Every other format, including OKLCH, Display P3, Tailwind, SwiftUI, Flutter and Android, is listed below the result and copies with one click.

Is this converter free?

Yes. It is free, needs no sign-up and runs entirely in your browser.