1. Home
  2. Developer tools
  3. Hex to UIColor & Android Color

Hex to UIColor & Android Color

Copy a brand colour from a design file into native mobile code for every platform at once, with the alpha in the right place.

Free, no sign-up. Runs in your browser: nothing is uploaded.

How to use Hex to UIColor & Android Color

  1. Type a hex colour (3, 4, 6 or 8 digits) or pick one.
  2. Check the swatch and RGB values.
  3. Copy the line for your platform.

Features

  • Swift UIKit, SwiftUI and Objective-C (0–1 components)
  • Android Color.parseColor and colors.xml
  • Jetpack Compose and Flutter Color(0xAARRGGBB)
  • React Native, CSS rgb(), .NET and Unity
  • #RRGGBBAA input with alpha moved to the front where needed

Supported formats

Input

  • Form input

You get

  • Copied text

Private by design

Everything you enter is processed by your browser on this device. Nothing is sent to openWorkstand or anyone else, so the Hex to UIColor & Android Color is safe for private and work data. After you have used it once while online, it also works without an internet connection. How local processing works

Good to know

  • Colours are sRGB; Display P3 colours from design tools need a P3 initialiser.

Guide

One hex colour in Swift, Android, Flutter and other platform code

Brand colours usually arrive as hex codes such as #3366CC in a design file or style guide, but native mobile code wants them in other forms: floating-point components on Apple platforms, a 32-bit ARGB number on Android and Flutter. Getting the alpha in the right place is where mistakes happen. This converter takes one hex colour and writes it for every common platform at once.

How a hex colour is built

A six-digit hex colour is three pairs of hexadecimal digits for red, green and blue, each from 00 to FF, which is 0 to 255 in decimal. #3366CC is red 51, green 102 and blue 204. Short three-digit forms double each digit, so #36C is the same colour. An eighth and ninth digit add alpha, the opacity, again from 00 for transparent to FF for opaque. In CSS and in this tool the alpha comes last: #3366CC80 is the same blue at about 50% opacity.

Ranges and alpha order

Platforms disagree in two ways. Apple’s UIKit, SwiftUI and Objective-C APIs take each component as a number from 0 to 1, so 51 becomes 0.2 and 204 becomes 0.8; the converter rounds to three decimals. Android, Jetpack Compose and Flutter pack the colour into one 32-bit integer with alpha first, written 0xAARRGGBB. That is why a fully opaque colour in Flutter is Color(0xFF3366CC) and why writing 0x3366CC there produces an invisible colour with alpha zero.

The outputs

For Apple platforms you get a UIKit UIColor(red:green:blue:alpha:), a SwiftUI Color(red:green:blue:) with opacity added only when the colour is not fully opaque, an Objective-C message and a hex-style line for projects that define a UIColor(rgb:) extension. For Android there is Color.parseColor("#…") for Java and Kotlin views, a colors.xml resource line, and Color(0x…) for Compose. Flutter gets Color(0x…), React Native a hex string or an rgba() string with alpha, and the web a CSS rgb() with slash syntax. .NET and Unity lines round off the set.

A worked example

The Sample button loads #3366CC80. The tool reads RGB 51, 102, 204 with alpha 128, which is 0.502. UIKit becomes UIColor(red: 0.2, green: 0.4, blue: 0.8, alpha: 0.502) and SwiftUI Color(red: 0.2, green: 0.4, blue: 0.8, opacity: 0.502). On Android the alpha moves to the front: Color.parseColor("#803366CC"), and Compose and Flutter both read Color(0x803366CC).

Picking and checking

The colour picker next to the text field sets the RGB part and keeps the alpha you typed, and the swatch shows the result, including transparency, so you can check that the code you copy is the colour you meant before it ends up in a pull request.

Colour spaces

All outputs assume sRGB, the colour space of the web and the default for most code. Wide-gamut displays on recent iPhones and Macs can show Display P3 colours, which design tools sometimes use. If a design specifies P3, use the platform’s P3 initialisers with the P3 values instead; converting hex alone cannot recover colours outside sRGB.

Keeping colours in one place

Rather than scattering literals through the code, define each brand colour once: an asset catalogue colour set on iOS, colors.xml or a Compose theme on Android, and a ThemeData in Flutter. Then this converter is only needed when the palette changes.

Checked against the current version of the Hex to UIColor & Android Color on .

Frequently asked questions

How do I add a UIColor(rgb:) initialiser?

Write a small extension: convenience init(rgb: UInt32) that divides each byte by 255, for example red: CGFloat((rgb >> 16) & 0xFF) / 255. The Swift hex line in the output assumes such an extension exists; the other Swift lines work without it.

Why does my colour look slightly different on the phone?

Design tools may work in Display P3 while the code uses sRGB, screens differ, and iOS can apply True Tone. If the design file is in P3, use UIColor(displayP3Red:green:blue:alpha:) or Color(.displayP3, …) with the values from the design tool.

Why does Flutter put FF in front of my colour?

Flutter’s and Compose’s Color(0x…) take a 32-bit ARGB number, alpha first. 0xFF3366CC is the colour #3366CC fully opaque; writing 0x3366CC would mean alpha 0, an invisible colour.

Is #3366CC80 alpha first or last?

In CSS and this tool, last: #RRGGBBAA. Android’s own hex strings put alpha first (#AARRGGBB), which is why the Android output reads #803366CC for the same colour.

Keep working with the result

openWorkstand also includes a free workspace with documents, spreadsheets, tasks, projects and a calendar that save to a folder on your computer.