Color to Mobile Code
Convert a hex colour to SwiftUI, UIKit, Jetpack Compose and Android XML code.
Translate one hex colour into iOS and Android code
Generate SwiftUI, UIKit, Jetpack Compose and Android XML representations from the same opaque RGB value.
#475569
hex
4
targets
100%
alpha
Colour input and preview
Six-digit RGB hexColor(red: 0.278, green: 0.333, blue: 0.412, opacity: 1)UIColor(red: 0.278, green: 0.333, blue: 0.412, alpha: 1)Color(0xFF475569)<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.
- 3Copy the snippet for SwiftUI, UIKit, Jetpack Compose or Android XML.
Examples
#475569Color(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.
Continue your workflow
Open a related tool to prepare your files or refine the finished result.
- ConvertersColor Converter
Convert colors between HEX, RGB, HSL, HSV and CMYK.
Open tool - Featured toolDeveloper ToolsWCAG Color Contrast Checker
Check colour contrast ratio against WCAG AA and AAA accessibility levels.
Open tool - CSS & DesignRandom Color Palette Generator
Generate random hex colour swatches and copy them individually or together.
Open tool
