GamutDesk Logo
GamutDesk

HEX to Jetpack Compose & Android XML Color Converter

Convert HEX to Jetpack Compose Color(0xFF...) and Android XML color resources with alpha. Copy ready-to-paste Kotlin and colors.xml snippets instantly.

Client-Side ArchitecturePrivate Client-Side Processing

Color

100%

Generated code

Jetpack Compose (Kotlin)
Color(0xFF3B82F6)
Android XML (colors.xml)
<color name="brand_primary">#FF3B82F6</color>

Technical Specification & Mathematical Principles

How the Android Color Converter Works

Android stores colors as 32-bit ARGB integers in the order alpha, red, green, blue. Web HEX puts alpha last (#RRGGBBAA), so the generator moves the alpha byte to the front: opacity 0.5 becomes 0x80 and #3B82F6 with full opacity becomes 0xFF3B82F6.

Jetpack Compose accepts that literal as Color(0xFF3B82F6). In XML resources the same value is written with a hash: <color name="brand_primary">#FF3B82F6</color>. Resource names must be lowercase letters, digits and underscores, so the tool normalizes whatever you type.

Frequently Asked Questions

Why does Android put alpha first?
Android packs a color into a 32-bit integer as 0xAARRGGBB, so the most significant byte holds alpha. CSS HEX does the opposite, with alpha as the last byte.
Do I need the L suffix in Kotlin?
No. Compose's Color(Long) constructor accepts the 0xFF3B82F6 literal directly. Kotlin infers a Long because the value exceeds Int range.
Where do I paste the XML snippet?
Place it inside the resources element of res/values/colors.xml, then reference it with @color/brand_primary in layouts or R.color.brand_primary in code.

Related Design & Color Instruments