Developer Tools
Color to Mobile Code
Convert a hex colour to SwiftUI, UIKit, Jetpack Compose and Android XML code.
Free foreverRuns in your browserNo sign-up
SwiftUI Color
Color(red: 0.278, green: 0.333, blue: 0.412, opacity: 1)UIKit UIColor
UIColor(red: 0.278, green: 0.333, blue: 0.412, alpha: 1)Jetpack Compose
Color(0xFF475569)Android colors.xml
<color name="my_color">#475569</color>Jetpack Compose and Android XML use the 0xAARRGGBB / #AARRGGBB form; the alpha is FF (opaque) here.
About the Color to Mobile Code
Designers hand off colours as hex codes, but iOS and Android need them in code. Converting by hand is fiddly and easy to get wrong.
This tool turns a hex colour into ready-to-paste SwiftUI Color, UIKit UIColor, Jetpack Compose Color and Android colors.xml snippets.
Pick a colour or type a hex value and copy the snippet you need.
Key features
- SwiftUI, UIKit, Compose and Android XML output
- Colour picker and hex input
- Live colour preview
- One-click copy per snippet
How to use
- 1Pick a colour or enter a hex value.
- 2Copy the snippet for your platform.
Examples
Slate colour
Input:
#475569Output:
Color(red: 0.278, green: 0.333, blue: 0.400, opacity: 1)The hex is split into sRGB components for SwiftUI, plus Compose and Android forms.
Frequently asked questions
- What colour spaces are used?
- SwiftUI and UIKit use sRGB components from 0 to 1. Jetpack Compose and Android XML use the 0xAARRGGBB / #AARRGGBB form. Alpha here is fully opaque (FF).
- Can I rename the Android colour?
- Yes. The colors.xml snippet uses my_color as a placeholder name; change it to your own resource name.
- Does it support 3-digit hex?
- Yes. Short hex like #ABC is expanded to the full 6-digit form before conversion.
