Color Picker
Pick any colour and copy it as HEX, RGB, HSL or CSS.
Turn a HEX code into SwiftUI Color, UIColor and NSColor code.
Used by the Asset Catalog output.
The Swift code appears here
HEX to SwiftUI Color writes the code rather than the numbers: a SwiftUI Color, a UIColor, an NSColor, the hex-string extension most projects end up writing, and the Asset Catalog JSON that gives you dark mode for free.
Neither SwiftUI nor UIKit takes a hex string. Both want floating-point components between 0 and 1, which means every colour from a design handoff has to be divided by 255 three times before it can be used.
This does that and writes the code. You get a SwiftUI Color initialiser, a UIColor for UIKit, an NSColor for AppKit, and the hex-string extension that most projects end up writing anyway, ready to paste into a shared file.
The Asset Catalog snippet is worth taking instead, for anything that needs a dark mode variant. Colours defined in an asset catalog get light and dark appearances for free and are resolved by the system, which is cleaner than branching on colorScheme in a view. The tool emits the JSON the catalog stores, with the sRGB colour space set explicitly.
Core Graphics wants 0–1 floats, so the division by 255 is done for you at full precision.
SwiftUI Color, UIColor for UIKit and NSColor for AppKit, so the right one is always there.
The Color(hex:) initialiser every project writes eventually, correct and ready for a shared file.
The better route for design system colours, since the catalog handles light, dark and high-contrast appearances.
The colour space is set in the output rather than left to a default, which is where wide-gamut surprises come from.
From a design file, a brand guide or the picker.
SwiftUI Color, UIColor or NSColor — or take all three.
Ready to paste, with the components already normalised.
The Asset Catalog form, which gives you a dark mode variant properly.
Because Core Graphics works in normalised floats throughout, which keeps it independent of bit depth. A 10-bit display and an 8-bit one use the same API.
An asset catalog for anything in your design system, because it handles light and dark appearances, high contrast variants and wide gamut without any code. A hex initialiser is fine for one-offs.
In SwiftUI, yes — it defaults to sRGB. UIColor(red:green:blue:alpha:) uses the extended sRGB space, which matters if you pass values outside 0–1 for wide gamut colours.
A hex code is an sRGB value by definition, so it converts to the same colour in P3 — you are not gaining gamut by declaring it P3. To use P3 properly you need colours authored in that space, not converted into it.
What people who use the HEX to SwiftUI Color think of it. Reviews come from visitors and are posted as written.
No ratings yet
Yours would be the first.
0 reviews
Newest first
No reviews yet
Be the first to rate the HEX to SwiftUI Color. It takes half a minute and no account.
Write the first reviewPick any colour and copy it as HEX, RGB, HSL or CSS.
Find the closest named colour to any HEX code.
Compute WCAG relative luminance and see the maths behind it.
See your palette as a real interface instead of swatches.
Convert HSL to HEX and back, with the maths written out.
Build a whole palette from one hue, and nothing else.
Find the true complement of any colour, and the near ones.
Fill headline text with a gradient, and keep it selectable.